Jump to content
Fivecord

Paste file from clipboard to blob field (Remote Desktop)

Recommended Posts

My application is working as Remote Desktop Application.

I want the user to copy files (jpg, word, excel, pdf) and paste them in my application, where the files will be processed in blobfields.

I found some code to get al the filenames in the clipboard, which works fine, but on the RD you cannot access the users local storage, thus I'm not able to read the file from the original location.

How dow I get the data + filename of each file (assuming it is possible to copy-paste multiple files) from the clipboard to storage them in a blobfield?

 

The code I found to get the filenames:

var
  f: THandle;
  buffer: Array [0..MAX_PATH] of Char;
  i, numFiles: Integer;
begin
  Clipboard.Open;
  try
    f := Clipboard.GetAsHandle(CF_HDROP);
    if f <> 0 then
    begin
      DragQueryFile
      numFiles := DragQueryFile(f, $FFFFFFFF, nil, 0);
      for i:= 0 to numfiles - 1 do
      begin
        buffer[0] := #0;
        DragQueryFile( f, i, buffer, sizeof(buffer));
        if FileExists(buffer) then
        begin
          //process file
		end;
      end;
    end;
  finally
    Clipboard.close;
  end;
end;

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×