For you WM_DROPFILES
is the only thing you need to handle. No need to fiddle with IDropTarget
etc.
If your application does not need to run in Admin mode, do not run it in admin mode. Disable the linker setting for the same (UAC Execution Level = asInvoker
). Also, run VS in non-Admin mode, so that your application also starts are non-Admin process. This way, Explorer.exe would be able to send WM_DROPFILES
message to your application.
If your application need to run as Admin mode, you need to allow other applications to send set of few messages to your application (window). Do the following:
ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
ChangeWindowMessageFilter(WM_COPYDATA, MSGFLT_ADD);
ChangeWindowMessageFilter(0x0049, MSGFLT_ADD);
You may also want to use newer function: ChangeWindowMessageFilterEx.
Note that, if your application must run as Admin, and you need to dynamically locate one of these function using GetProcAddress
, so that your application can run on OS where this function is not available (eg. Windows XP).