Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to get the file name (and directory) of a file in the clipboard Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Aug-02
Category
Files Operation
Language
Delphi 2.x
Views
113
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I need to have the filename and directory of the file which is in the clipboard. 
For example: In the Explorer I select a file, press ctrl+c and in my application I 
would like copy or do anything with it.

Answer:

1   procedure TMainForm.Button1Click(Sender: TObject);
2   var
3     hDrop: THandle;
4     cnt, i: Integer;
5     filename: array[0..MAX_PATH - 1] of Char;
6   begin
7     if ClipBoard.HasFormat(CF_HDROP) then
8     begin
9       hDrop := ClipBoard.GetAsHandle(CF_HDROP);
10      cnt := DragQueryFile(hDrop, $FFFFFFFF, nil, 0);
11      Memo.Clear;
12      Memo.Lines.Add(Format('Found %d files:', [cnt]));
13      for i := 0 to cnt - 1 do
14      begin
15        DragQueryFile(hDrop, i, @filename, MAX_PATH);
16        Memo.lines.Add(Format('%2d: %s', [i + 1, filename]));
17      end;
18    end
19    else
20      MessageDlg(' No filename in clipboard!', mtInformation, [mbOk], 0);
21  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC