C# Drag drop does not work on windows 7
Solution 1:
The source and target processes need to have compatible security levels/privileges. For example, if your source is Explorer and it is running with user level privileges, but your target application is running with administrator (elevated) level permission, you will not be able to drag&drop as this is seen as a security issue as the target is running with a higher level of privileges.
Solution 2:
It is called UIPI, User Interface Privilege Isolation. Designed to prevent input injection exploits from programs that run with restricted privileges. It can be disabled, you'll need to do this:
- Modify the manifest, set the uiAccess attribute for the
<requestedExecutionLevel>
element to true. - Store your program's EXE in a subdirectory of c:\windows or c:\program files
- Sign your EXE with a certificate from an valid code signing authority
Never actually tried this, ymmv.
Solution 3:
From your application, call ChangeWindowMessageFilter with the following values to allow dragging and dropping to/from your elevated application and non-elevated applications like Explorer:
ChangeWindowMessageFilter (WM_DROPFILES, MSGFLT_ADD);
ChangeWindowMessageFilter (WM_COPYDATA, MSGFLT_ADD);
ChangeWindowMessageFilter (0x0049, MSGFLT_ADD);
Solution 4:
A Minor addition to dmex's post. The following defines the variables and the constant.
private const uint WM_DROPFILES = 0x233;
private const uint WM_COPYDATA = 0x004A;
private const uint WM_COPYGLOBALDATA = 0x0049;
private const uint MSGFLT_ADD = 1;
Also, you may want to consider using ChangeWindowMessageFilterEx
if you're application is on Windows 7. I also believe that OLE drag and drop may not use Windows messaging. So it wouldn't effect that at all.