| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 644 人关注过本帖
标题:请教有关HOOK的问题? ^Q^
只看楼主 加入收藏
fx_170601
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-11-30
收藏
 问题点数:0 回复次数:4 
请教有关HOOK的问题? ^Q^
最近在学hook的一些方法,苦于无完整且又简单的例子,请各位大虾写几个!小生不胜感激!
搜索更多相关主题的帖子: HOOK 
2005-11-30 15:33
fx_170601
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2005-11-30
收藏
得分:0 

********************************************************************
*标准模块下代码!
*
*********************************************************************
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! 各位打虾帮一下!

2005-11-30 20:55
ryu
Rank: 1
等 级:新手上路
帖 子:124
专家分:0
注 册:2006-2-12
收藏
得分:0 
键值错误:
Select Case wparam
Case vbKeySnapshot '?? 有没有按到PrintScreen?
MyKBHFunc = 1 '在?个Hook便吃掉?个?息
pstrMsg = pstrMsg + "1"
Case VK_RBUTTON
pstrMsg = pstrMsg + "2"
End Select

本帖版权归ryu所有.如果引用本帖,请注明帖子的出处和作者;本帖如系引用,其版权归原作者所有.
2006-02-13 13:26
小伟的小伟
Rank: 1
等 级:禁止访问
帖 子:122
专家分:0
注 册:2006-1-25
收藏
得分:0 

2006-02-13 13:43
wl5518
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2006-6-13
收藏
得分:0 

不知道怎么做呀??

2006-06-13 11:26
快速回复:请教有关HOOK的问题? ^Q^
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030893 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved