如何阻止windows关机?
来源:互联网 发布:一级已备案域名购买 编辑:程序博客网 时间:2024/04/29 04:54
如何阻止windows关机?
'mStopShutDown.bas
模块代码:
Private Const GWL_WNDPROC = (-4)
Private Const WM_ENDSESSION = &H16
Private Const WM_QUERYENDSESSION = &H11
Private WndProc As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc
As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As
Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long,
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Sub HookShutDown(ByVal hWnd As Long)
If WndProc = 0 Then
WndProc = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
End If
End Sub
Public Sub UnHookShutDown(ByVal hWnd As Long)
If WndProc <> 0 Then
Call SetWindowLong(hWnd, GWL_WNDPROC, WndProc)
WndProc = 0
End If
End Sub
Private Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal
lParam As Long) As Long
If uMsg = WM_QUERYENDSESSION Then
WindowProc = False '为0
Exit Function
ElseIf uMsg = WM_ENDSESSION Then
WindowProc = False '为0
Exit Function
End If
WindowProc = CallWindowProc(WndProc, hw, uMsg, wParam, lParam)
End Function
主窗体代码:
Private Sub Form_Load()
Call HookShutDown(Me.hWnd)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call UnHookShutDown(Me.hWnd)
End Sub
- 如何阻止windows关机?
- 阻止windows关机
- 获得关机消息;阻止Windows关机
- MFC: 获得关机消息;阻止Windows关机
- 桌面程序阻止Windows关机
- 处理WM_QUERYENDSESSION 阻止Windows关机事件
- Windows 7下阻止系统关机
- 阻止关机
- 如何禁止Windows关机
- C# 阻止电脑关机
- C++, Qt Windows关机的时候,阻止其关机或这注销 做其它业务的解决方法
- 如何去掉Windows 2003的关机提示
- 如何实现windows XP定时关机?
- C#如何捕获windows关机事件
- 如何控制Windows的关机或重新启动
- 教你如何让windows定时关机
- 使用python如何实现Windows定时关机?
- Windows关机或重启显示有程序正在阻止、程序失去响应
- 边界跟踪 边缘检测 边缘连接
- VC数字图像处理编程讲座之十
- 最恨强行捆绑
- JS正则表达式整理(不断更新中...)
- 群集配置(作者:xjunhua (沉思的森林) )
- 如何阻止windows关机?
- webwork 与 spring 集成的方式
- 自考信息
- viewstate
- 一组VB实用小程序
- 把文学和市场结合起来
- VB 串口编程调试代码(1)
- 《串口编程调试代码》之二
- 串口编程调试代码》之三