autoit写的程序能监听到关机或登出时的消息吗
1个回答
展开全部
DllCall("Kernel32", "ubyte", "SetProcessShutdownParameters", "dword", 1024, "dword", 1) ;更改关机级别 0 - 1024 级别越高程序在系统关闭时越早关闭
#cs
BOOL WINAPI SetProcessShutdownParameters(
__in DWORD dwLevel,
__in DWORD dwFlags
);
#ce
GUIRegisterMsg(0x0011, "WindowProc")
GUIRegisterMsg(0x0016, "WindowProc")
#cs
#define WM_QUERYENDSESSION 0x0011
#define WM_ENDSESSION 0x0016
#ce
#cs
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // not used
LPARAM lParam // logoff option
);
#ce
GUICreate("test")
$Edit = GUICtrlCreateEdit("", 50, 35, 300, 330)
GUISetSTate()
Do
Until GUIGetMsg() = -3
Func WindowProc($hWnd, $MsgID, $WParam, $LParam)
GUICtrlSetData($Edit,GUICtrlRead($Edit) & "Time: " & StringFormat("%2d:%2d:%2d",@HOUR,@MIN,@SEC) & @CRLF& "Msg: 0x" & Hex($MsgID) & @CRLF& "LParam: 0x" & Hex($LParam) & @CRLF)
Return False
EndFunc
#cs
BOOL WINAPI SetProcessShutdownParameters(
__in DWORD dwLevel,
__in DWORD dwFlags
);
#ce
GUIRegisterMsg(0x0011, "WindowProc")
GUIRegisterMsg(0x0016, "WindowProc")
#cs
#define WM_QUERYENDSESSION 0x0011
#define WM_ENDSESSION 0x0016
#ce
#cs
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // not used
LPARAM lParam // logoff option
);
#ce
GUICreate("test")
$Edit = GUICtrlCreateEdit("", 50, 35, 300, 330)
GUISetSTate()
Do
Until GUIGetMsg() = -3
Func WindowProc($hWnd, $MsgID, $WParam, $LParam)
GUICtrlSetData($Edit,GUICtrlRead($Edit) & "Time: " & StringFormat("%2d:%2d:%2d",@HOUR,@MIN,@SEC) & @CRLF& "Msg: 0x" & Hex($MsgID) & @CRLF& "LParam: 0x" & Hex($LParam) & @CRLF)
Return False
EndFunc
金山毒霸
2024-10-31 广告
2024-10-31 广告
大部分系统错误,是因为某些DLL文件丢失造成的,比如未安装DirectX9或DirectX 9.0组件已损坏、缺少Visual C ++库、未安装.net库。解决方法如下:一、 手动解决方法1、先确定电脑操作系统是多少位的,现在的电脑一般都...
点击进入详情页
本回答由金山毒霸提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询