Drop files on the form and administrator privileges lazarus / 31-LCL ---------------------------------------------------------------------- Tomo · 2012-10-18 08:39 Hi there, I have a problem with dropping files and administrator privileges. What I want to achieve is simple - dropping files from the explorer to CheckListBox and adding items with path to it. I'm using ApplicationProperties component to do so. The code is: Code: [Select]procedure TForm1.ApplicationProperties1DropFiles(Sender: TObject;   const FileNames: array of String); var   I: Integer; begin   for I := 0 to High(FileNames) do     CheckListBox1.Items.Add(FileNames[I]); end;          And this code only works when I uncheck "Run as administrator" in the file (my application exe) properties. When I run as an administrator it doesn't work, nothing happens. I must run it as an administrator, otherwise I can't modify the registry from my application. I'm using Win 7 32 bit and Lazarus 1.0. ---------------------------------------------------------------------- Timewarp · 2012-10-18 09:38 Quote from: Tomo on October 18, 2012, 10:39:52 amWhen I run as an administrator it doesn't work, nothing happens. I don't use "ApplicationProperties1DropFiles", I do it different way, but I had the same problem. I needed to do this to get dropfiles working in my application Delphi + Windows 7 +  administrator. Code: [Select]uses Windows; type   TChangeWindowMessageFilter = function(msg: Cardinal; Action: Dword): BOOL; stdcall; var   User32Module: THandle;   ChangeWindowMessageFilterPtr: Pointer; function CheckUser32Module: Boolean; begin  if User32Module=0 then User32Module:=safeLoadLibrary('USER32.DLL');  Result:=User32Module>HINSTANCE_ERROR; end; function CheckUser32ModuleFunc(const Name: string; var ptr: Pointer): Boolean; begin  Result:=CheckUser32Module;  if Result then   begin    ptr:=GetProcAddress(User32Module, PChar(Name));    Result:=Assigned(ptr);    if not Result then ptr:=Pointer(1);   end; end; function ChangeWindowMessageFilter(msg: Cardinal; Action: Dword): BOOL; begin  if (Integer(ChangeWindowMessageFilterPtr) > 1) or   CheckUser32ModuleFunc('ChangeWindowMessageFilter', ChangeWindowMessageFilterPtr) then  Result:=TChangeWindowMessageFilter(ChangeWindowMessageFilterPtr)(Card inal(msg), action)  else Result:=false; end; procedure TForm1.FormCreate(Sender: TObject); const   WM_COPYGLOBALDATA = 73;   MSGFLT_ADD = 1; begin  try   ChangeWindowMessageFilter(WM_COPYGLOBALDATA, MSGFLT_ADD);   ChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);  except; end; end; procedure TForm1.FormDestroy(Sender: TObject); begin  if User32Module<>0 then FreeLibrary(User32Module); end; ---------------------------------------------------------------------- Tomo · 2012-10-18 10:25 Thanks, that snippet helped to fix the problem. I would never make it work by myself, someone could report this behaviour on the bugtracker. ---------------------------------------------------------------------- Timewarp · 2012-10-18 10:34 Quote from: Tomo on October 18, 2012, 12:25:44 pmsomeone could report this behaviour on the bugtracker. It's not a bug, but new "feature" of Windows 7. You don't have this problem in XP. Wonder how many applications are broken in 7 because of this.. ---------------------------------------------------------------------- BigChimp · 2012-10-18 10:59 Quote from: Tomo on October 18, 2012, 12:25:44 pmThanks, that snippet helped to fix the problem. I would never make it work by myself, someone could report this behaviour on the bugtracker. Well, a section in the wiki (e.g. in the Windows article) might also be a good idea...