Windows 8 x64 I can't drag&drop files from Windows Explo

Please report only one bug per message!

Moderators: white, Hacker, petermad, Stefan2

jurot
Junior Member
Junior Member
Posts: 5
Joined: 2013-03-12, 08:16 UTC

Windows 8 x64 I can't drag&drop files from Windows Explo

Post by *jurot »

I have OS Windows 8 x64 and using TC x64 v. 8.01 and I can't drag&drop files from Windows Explorer.
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

If you're running elevated TC instance, you can't drag files from non-elevated windows to it, it is a Windows security restriction. So you shouldn't run TC in elevated mode to make drag-n-drop working.
jurot
Junior Member
Junior Member
Posts: 5
Joined: 2013-03-12, 08:16 UTC

Post by *jurot »

Sorry, but I don't understand what do you mean with "elevated" or "non-elevated"... You mean if I ran it as an administrator?
umbra
Power Member
Power Member
Posts: 871
Joined: 2012-01-14, 20:41 UTC

Post by *umbra »

Yes, exactly.
Windows 7 Pro x64, Windows 10 Pro x64
jurot
Junior Member
Junior Member
Posts: 5
Joined: 2013-03-12, 08:16 UTC

Post by *jurot »

I'm running TC as administrator.

But I tried to run TC as non-administrator - no change.
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6489
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Post by *Horst.Epp »

jurot wrote:I'm running TC as administrator.

But I tried to run TC as non-administrator - no change.
Running as Administrator is not elevated !
Elevated is when the UAC asks for more rights and you say yes.
Drag and Drop from normal Windows Explorer to any normal running TC works fine here for the same environment.
jurot
Junior Member
Junior Member
Posts: 5
Joined: 2013-03-12, 08:16 UTC

Post by *jurot »

I really miss this funcionality ... it's possible to do something with that?
User avatar
MVV
Power Member
Power Member
Posts: 8702
Joined: 2008-08-03, 12:51 UTC
Location: Russian Federation

Post by *MVV »

jurot,
When you run TC w/o 'Run as Administrator' (w/o UAC popup), drag-n-drop should work fine.
umbra
Power Member
Power Member
Posts: 871
Joined: 2012-01-14, 20:41 UTC

Post by *umbra »

2jurot
Is it really necessary for you to run TC with admin privileges? For example, most of the time I don't need them. And when I want to do a bunch of operations that need such privileges, TC asks me for them and I choose "All as Administrator". That way TC won't asks for them again for a few minutes and usually that's all the time I need.
It's safer this way, not too cumbersome (at least for me) and it solves a few issues (like the drag-and-drop).
Windows 7 Pro x64, Windows 10 Pro x64
jurot
Junior Member
Junior Member
Posts: 5
Joined: 2013-03-12, 08:16 UTC

Post by *jurot »

Ok .. I will try to live without admin privilegies in TC :)

Thanks.
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

The problem will be solved in the future, as the Author said, maybe in Total Commander 8.1. See this thread: http://www.ghisler.ch/board/viewtopic.php?t=34523.

Regards
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Actually I have tried this workaround, but it doesn't work with OLE drag&drop, because it uses callbacks and not Windows messages.

Here you can find the explanation why it doesn't work: Stackoverflow
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Mmmhmm, strange. They tell in this thread about RegisterDragDrop API, which uses IDropTarget interface. Is there any reason for using interfaces directly, in order to be a _target_ of drag&drop operations?

The simple code below works for me. I just tested it now with Win7 64-bit, my elevated application was 32-bit and I successfully draged&dropped files from Explorer to this application. After removing "DragDropInit(Handle);" line, application - when elevated - stopped to receive drag&drop from Explorer.

Code: Select all

unit Unit1;

interface

uses
  Messages, Classes, Controls, Forms, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    procedure WMDropFiles(var Message : TMessage); message WM_DROPFILES;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  Windows, ShellAPI;

procedure TForm1.FormCreate(Sender: TObject);
begin
  DragDropInit(Handle); {http://www.ghisler.ch/board/viewtopic.php?t=34523}
  DragAcceptFiles(Handle,True);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  DragAcceptFiles(Handle,False);
end;

procedure TForm1.WMDropFiles(var Message : TMessage);
var
  I : Cardinal;
  FileName : packed array[0..MAX_COMPUTERNAME_LENGTH+MAX_PATH] of AnsiChar;
begin
  Memo1.Clear;
  I:=DragQueryFile(Message.wParam,Cardinal(-1),FileName,Length(FileName));
  for I:=0 to I-1 do
  if DragQueryFile(Message.wParam,I,FileName,SizeOf(FileName)) > 0 then
  begin
    Memo1.Lines.Add(FileName);
    Application.BringToFront;
  end;
  DragFinish(Message.wParam);
  {Don't call "inherited" here!}
end;

end.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48083
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

Yes, TC is registering IDropTarget so it can receive OLE objects other than files (e.g. drags from virtual folders or mail attachments).
Author of Total Commander
https://www.ghisler.com
User avatar
MarcinW
Power Member
Power Member
Posts: 852
Joined: 2012-01-23, 15:58 UTC
Location: Poland

Post by *MarcinW »

Well, Microsoft states that there is definitely no way to perform drag&drop from non-elevated to elevated applications, when using COM objects:

The COM Elevation Moniker: "Drag and drop is not allowed from non-elevated to elevated applications."
Post Reply