Windows下win32编程管理员权限下运行,支持窗口文件拖动处理
__inline static
void RegisterDropFilesEvent(HWND hWnd)
{
#ifndef WM_COPYGLOBALDATA
#define WM_COPYGLOBALDAYA 0x0049
#endif
#ifndef MSGFLT_ADD
#define MSGFLT_ADD 1
#endif
#ifndef MSGFLT_REMOVE
#define MSGFLT_REMOVE 2
#endif
SetWindowLong(hWnd, GWL_EXSTYLE, GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_ACCEPTFILES);
typedef BOOL(WINAPI* LPFN_ChangeWindowMessageFilter)(__in UINT message, __in DWORD dwFlag);
LPFN_ChangeWindowMessageFilter pfnChangeWindowMessageFilter = (LPFN_ChangeWindowMessageFilter)GetProcAddress(GetModuleHandle(_T("USER32.DLL")), "ChangeWindowMessageFilter");
if (pfnChangeWindowMessageFilter)
{
pfnChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
pfnChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
pfnChangeWindowMessageFilter(WM_COPYGLOBALDAYA, MSGFLT_ADD);
}
}