Wednesday, December 19, 2012

ShellExecute as administrator + Drag and Drop in Windows 7

This is a little tip that took me sometime to figure it out:
This kind of issue happened when I was debugging a IntraWeb application created with Delphi XE3 in Windows 7. I often run Delphi XE3 as local administrator. I know, I know... but sometimes it is required for proper ISAPI debugging.
This application renders a control that supports drag and drop from Windows Explorer, when the browser also supports it (Firefox, Chorme, etc.). The issue then is: When you start the browser using ShellExecute (or CreateProcess for that matter), from Delphi XE3 (or any other version or software) running with administrator credentials, the browser is also running as administrator, right? But Windows Explorer IS NOT. So, drag and drop from Windows Explorer to Firefox, for instance, won't work. Applications running with elevated privileges and applications running as regular user just won't do drag and drop... Simple, yes?


Olaf said...

If you use "WM_DropFiles" to process the dropped files calling
"ChangeWindowMessageFilter" (introduced with Vista) or "ChangeWindowMessageFilterEx" (introducted with Windows 7) might allow a lower priority process to send messages to an elevated one.

Alexandre Caldas Machado said...

Hi Olaf,

thanks for your feedback. But in this case I don't have controls over both processes, because I start dragging from Windows Explorer, and they are dropped on the browser (Firefox mostly). My application is only on the server side.

Anonymous said...

I hope you choose since they are the best online site Besides, they provided genuine keys to me.I am very appreciated. Great work! Strongly recommended.