Capture filenames from Clipboard  

Send By: Radikal (Q3 Team)
Web : http://www.q3.nu
Email: radikal@q3.nu
Date: 14/01/04

Tip accessed 478 times

 




 procedure TForm1.Button1Click(Sender: TObject);
 // uses: ClipBrd, ShellApi
 var
   Mango        : THandle;
   Cuantos, n   : Integer;
   Fichero      : array [0..MAX_PATH - 1] of char;
 begin
   if ClipBoard.HasFormat(CF_HDROP) then
   begin
     Mango := ClipBoard.GetAsHandle(CF_HDROP);
     Cuantos := DragQueryFile(Mango, $FFFFFFFF, nil, 0);
     Memo1.Clear;
     Memo1.Lines.Add( 'Encontrados' +
                      IntToStr(Cuantos)+
                      ' ficheros en el portapapeles:'+#13+#10);
     for n := 0 to Pred(Cuantos) do
     begin
       DragQueryFile(Mango, n, @Fichero, MAX_PATH);
       Memo1.lines.Add ( IntToStr(n)+':'+
                         Fichero );
     end;
   end
   else
     ShowMessage( 'No hay ficheros en el portapepeles'+#13+#10+
                  'No filenames in clipboard' );
 end;