怎么样Hook文件拖拽WM_DROPFILES

fengdongping001 2013-06-09 01:39:10
我想获得鼠标从一个目录拖拽文件到另外一个目录时,文件的位置,所以就想用HOOK,拦截WM_DROPFILES
以下是dll中的代码。但是HOOK不到WM_DROPFILES。
HINSTANCE hDll=NULL;
HHOOK g_hHook = 0; //HOOK句柄
HWND g_hWnd = 0;
__declspec(dllexport) int GetWindowTextRemote(HWND hWnd, LPSTR lpString)
{
g_hWnd = hWnd;
DWORD id = GetWindowThreadProcessId(hWnd,NULL);
//给目标进程安装一个窗口过程钩子
g_hHook = SetWindowsHookEx(WH_CALLWNDPROC,(HOOKPROC)HookProc,
hDll, 0 );

if( g_hHook==NULL ) {
lpString[0] = '\0';
return 0;
}

AfxMessageBox("Hook安装成功");
}


LRESULT HookProc (
int code, // hook code
WPARAM wParam, // virtual-key code
LPARAM lParam // keystroke-message information
)
{
if(code>=0)
{
LPCWPSTRUCT lpmsg=(LPCWPSTRUCT)lParam;
if(lpmsg->message == WM_DROPFILES)
{
int kk = 0;
AfxMessageBox("WM_DROPFILES");
}


}


//将消息处理权转让给下一个钩子函数
return CallNextHookEx(g_hHook, code, wParam, lParam);
}
...全文
341 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengdongping001 2013-06-09
  • 打赏
  • 举报
回复
HOOK WH_GETMESSAGE 就能hook WM_DROPFILES
赵4老师 2013-06-09
  • 打赏
  • 举报
回复
http://www.codeproject.com搜“Shell Extension”
赵4老师 2013-06-09
  • 打赏
  • 举报
回复
Setting a Breakpoint on a Message Received by a Windows Function You can set message breakpoints to stop the debugger when a particular WndProc function message is received. Note Message breakpoints work only on x86- or Pentium-based systems. To set a breakpoint on a message 1. From the Edit menu, click Breakpoints. The Breakpoints dialog box appears. 2. Click the Messages tab. 3. In the Break At WndProc text box, type the name of the Windows function. If you are setting a breakpoint during a debug session, the list contains the exported functions in your project. 4. In the Set One Breakpoint For Each Message To Watch list box, select the message. 5. To set another breakpoint, press ENTER, and then repeat steps 3 and 4. The Breakpoints list displays the currently active breakpoints. 6. Click OK to set the breakpoints. Note If you interrupt execution while Windows or other system code is running, the results can be unpredictable.

64,661

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧