provent from sleep?

typedef struct UUID{ int d1, d2, d3, d4 } LPCGUID; //At program start //GWL_WNDPROC = -4 //ES_CONTINUOUS = 0x80000000 //ES_SYSTEM_REQUIRED = 0x1 //ES_AWAYMODE_REQUIRED = 0x40 //GUID_SYSTEM_AWAYMODE = "98a7f580-01f7-48aa-9c0f-44352c29e5C0" LPCGUID uid; oldWndProc = SetWindowLong(this.hWnd, GWL_WNDPROC, &MyWndProc) SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED) UuidFromStringA(*(GUID_SYSTEM_AWAYMODE), uid) ps = RegisterPowerSettingNotification(this.hWnd, uid, 0) //In MyWndProc(hWnd, wMsg, wParam, lParam) //WM_POWERBROADCAST = 0x218 //PBT_POWERSETTINGCHANGE = 0x8013 if wMsg = WM_POWERBROADCAST && wParam = PBT_POWERSETTINGCHANGE ( //CALL YOUR FUNCTION HERE! //You can additionally extract data from the lParam to verify //this is the notification you're waiting for (see below) ) return CallWindowProc(oldWndProc, hWnd, wMsg, wParam, lParam) //Before exiting SetWindowLong(Me.hWnd, GWL_WNDPROC, oldWndProc) UnregisterPowerSettingNotification(ps)

你可能感兴趣的:(provent from sleep?)