********************************************************************
*标准模块下代码!
*
*********************************************************************
Option Explicit
Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
'Public Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Public Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal ncode As Long, ByVal wparam As Long, lparam As Any) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public hHook As Long
Public Const WH_CALLWNDPROC = 4
Public Const WH_CALLWNDPROCRET = 12
Public Const WH_CBT = 5
Public Const WH_DEBUG = 9
Public Const WH_FOREGROUNDIDLE = 11
Public Const WH_GETMESSAGE = 3
Public Const WH_HARDWARE = 8
Public Const WH_JOURNALPLAYBACK = 1
Public Const WH_JOURNALRECORD = 0
Public Const WH_KEYBOARD = 2
Public Const WH_MOUSE = 7
Public Const WH_MSGFILTER = (-1)
Public Const WH_SHELL = 10
Public Const WH_SYSMSGFILTER = 6
Public Const HC_ACTION = 0
'Public Const WH_KEYBOARD = 2
Public Const VK_SNAPSHOT = &H2C
Public Const WM_KEYDOWN = 13
Public pstrMsg As String
Public Sub UnHookKBD()
If hHook <> 0 Then
UnhookWindowsHookEx hHook
hHook = 0
End If
End Sub
Public Function EnableKBDHook()
If hHook <> 0 Then
Exit Function
End If
hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf _
MyKBHFunc, App.hInstance, App.ThreadID)
End Function
Public Function MyKBHFunc(ByVal icode As Long, _
ByVal wparam As Long, ByVal lparam As Long) As Long
MyKBHFunc = 0 '表示要?理?个?息
Select Case wparam
Case vbKeySnapshot '?? 有没有按到PrintScreen?
MyKBHFunc = 1 '在?个Hook便吃掉?个?息
pstrMsg = pstrMsg + "1"
Case VK_RBUTTON
pstrMsg = pstrMsg + "2"
End Select
Call CallNextHookEx(hHook, icode, wparam, lparam) '??下一个Hook
End Function
********************************************************************
*FORM下代码!
*
*********************************************************************
Private Sub Command1_Click()
Text1.Text = pstrMsg
End Sub
Private Sub Form_Load()
Call EnableKBDHook
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call UnHookKBD
End Sub
问题点以为红字
问题: 为何一按printscreen便关闭了vb! 各位打虾帮一下!