本人今天弄的一个程序,可是代码出了点问题,大哥大姐帮忙解决一下??
源程序在附件里面
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
Declare Function setwindowlong Lib "user32" Alias "setwindowlongA" (ByVal hwnd As Long, ByVal nlndex As Long, ByVal dwnewlong As Long) As Long
Public Const GWL_WNDPROC = -4
Global lpprevwndproc As Long
Global gHW As Long
Const WM_QUERYENDSESSION = &H11
Public Sub Hook()
lpprevwndproc = setwindowlong(gHW, GWL_WNDPROC, AddressOfwindowproc)
End Sub
Public Sub unhook()
Dim temp As Long
temp = setwindowlong(gHW, GWL_WNDPROC, lpprevwndproc)
End Sub
Function windwoproc(ByVal hw As Long, ByVal umsg As Long, ByVal wparam As Long, ByVal lparam As Long) As Long
Select Case umsg
Case WM_QUERYENDSESSION
frmdislogOFF.msginfo.AddItem "捕获到结束当前会话消息" & IIf(frmdislogOFF.chkenable.Value = vbChecked, "允许!", "禁止!")
windowproc = IIf(frmdislogOFF.chkenable.Value = vbChecked, 1, 0)
Exit Function
Case Else
windowproc = CallWindowProc(lpprevwndproc, hw, umsg, wparam, iparam)
End Select
End Function
[此贴子已经被作者于2007-10-25 21:24:47编辑过]