响应WM_QUERYENDSESSION 消息:
The WM_QUERYENDSESSION message is sent when the user chooses to end the Windows session or when an application calls the ExitWindows function. If any application returns zero, the Windows session is not ended. Windows stops sending WM_QUERYENDSESSION messages as soon as one application returns zero. After processing this message, Windows sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message. WM_QUERYENDSESSION
nSource = (UINT) wParam; // source of end-session request
fLogOff = lParam // logoff flag
Parameters
nSource Reserved for future use. fLogOff Value of lParam. Indicates whether the user is logging off or shutting down the system. Supported values include: ENDSESSION_LOGOFF.
The WM_QUERYENDSESSION message is sent when the user chooses to end the Windows session or when an application calls the ExitWindows function. If any application returns zero, the Windows session is not ended. Windows stops sending WM_QUERYENDSESSION messages as soon as one application returns zero. After processing this message, Windows sends the WM_ENDSESSION message with the wParam parameter set to the results of the WM_QUERYENDSESSION message. WM_QUERYENDSESSION
nSource = (UINT) wParam; // source of end-session request
fLogOff = lParam // logoff flag
Parameters
nSource Reserved for future use. fLogOff Value of lParam. Indicates whether the user is logging off or shutting down the system. Supported values include: ENDSESSION_LOGOFF.
解决方案 »
- 用FSO上传文件到服务器
- DataGrid控件标题居中
- 将字符串视为代码,可以实现吗?
- 局域网内,用VB如何读写其他电脑中某目录下的一个文本文件
- 求软件界面设计好的程序源代码或可下载网址,在线等候
- 将文件保存到数据库中,将数据库中的文件下载,各位高手有什么好方法。。
- 请教个小问题,list控件是如何显示两例的。我现在在做个小程序,要用到LIST控件,在按添加按钮后,要把 Text1.text 和Text2.text 的内容
- 如何解决数据库中数据量很多很多时程序执行很慢
- 在vb中怎么访问网络上的mdb文件?比如ftp://***.com/*.mdb
- 请问高手怎样用程序(最好是一个函数)关掉一个多线程中的exe文件?
- vb也升级到.net了,我们vb6 程序员该怎么办?
- Listview 图标排序问题
Private Sub Form_Load()
oldwinproc = GetWindowLong(Me.hWnd, GWL_WNDPROC)
SetWindowLong Me.hWnd, GWL_WNDPROC, AddressOf OnMenu
End Sub
Private Sub Form_Unload(Cancel As Integer)
SetWindowLong Me.hWnd, GWL_WNDPROC, oldwinproc
End Submodule code
Option ExplicitPublic Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public 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
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Const GWL_WNDPROC = (-4)
Public oldwinproc As Long
Public Const WM_QUERYENDSESSION = &H11Public Function OnMenu(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case wMsg
Case WM_QUERYENDSESSION
MsgBox "系统要关机了"
End Select
OnMenu = CallWindowProc(oldwinproc, hWnd, wMsg, wParam, lParam)
End Function