1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#pragma once
#ifndef WM_COPYGLOBALDATA
#define WM_COPYGLOBALDATA 0x0049
#endif
typedef WINUSERAPI BOOL WINAPI CHANGEWINDOWMESSAGEFILTER(UINT message, DWORD dwFlag);
//修复OnDropFile在win7管理员权限下接收不到的问题
void DropFileFix()
{
HINSTANCE hDllInst = LoadLibrary(_T("user32.dll"));
if (hDllInst)
{
CHANGEWINDOWMESSAGEFILTER *pAddMessageFilterFunc = (CHANGEWINDOWMESSAGEFILTER *)GetProcAddress(hDllInst, "ChangeWindowMessageFilter");
if (pAddMessageFilterFunc)
{
pAddMessageFilterFunc(WM_DROPFILES, MSGFLT_ADD);
pAddMessageFilterFunc(WM_COPYDATA, MSGFLT_ADD);
pAddMessageFilterFunc(0x0049, MSGFLT_ADD);
}
FreeLibrary(hDllInst);
}
}
|
在程序入口或对话框初始化函数中调用DropFileFix() 即可解决vista和win7中使用管理员权限接收不到WM_DROPFILES(OnDropFiles())消息的问题。
http://blog.csdn.net/ningbinzhang/article/details/39956801
https://blog.twofei.com/602/
http://blog.sina.com.cn/s/blog_6294abe70101bko6.html