on Windown Mobile 6, under Settings\System\Power\Misc there is a "Disable Power Switch" what I have to check programatically to get rid of popup menu. By comparing registried I figured out, that it can be set trough 'Drivers\BuiltIn\Power\Settings' registry key, settings DisablePwrSwitch to 1.
The problem is, that it is not enough to set registry, you also have to set event for the driver to force him to reload settings (or you can reset device, but it is an ugly solution).
I can achieve it teoretically with:
private static void DoAutoResetEvent()
{
string eventString = "OMNIBOOK_EVENT_SHUTDOWN";
IntPtr newHandle = CreateEvent(IntPtr.Zero, false, false, eventString);
EventModify(newHandle, (int)EventFlags.EVENT_SET);
CloseHandle(newHandle);
}
private enum EventFlags
{
EVENT_PULSE = 1,
EVENT_RESET = 2,
EVENT_SET = 3
}
[DllImport("coredll.dll", SetLastError = true)]
private static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName);
[DllImport("coredll")]
static extern bool EventModify(IntPtr hEvent, int func);
[DllImport("coredll.dll", SetLastError = true)]
private static extern bool CloseHandle(IntPtr hObject);
But I do not know the actual eventStrign for that. "OMNIBOOK_EVENT_SHUTDOWN"
is of course not the correct one.
Have somebody an idea, what is the eventName to reload settings by this driver?