I have just found this code to get files from the clipboard and it works fine, but I would like to make it a Boolean function so that I know it succeeded. What do I need to test to see if it has the file(s) on the clipboard and that all is OK?
USES Clipbrd, shellapi;
// procedure GetFileNameFromClipboard(oSL : TStringlist);
function GetFileNameFromClipboard(oSL : TStringlist) : Boolean;
var
f: THandle;
buffer: array [0..MAX_PATH] of Char;
i, c: Integer;
begin
Result:=False;
if NOT Clipboard.HasFormat(CF_HDROP) then exit;
Clipboard.Open;
f := Clipboard.GetAsHandle(CF_HDROP);
if f <> 0 then
begin
c := DragQueryFile(f, $FFFFFFFF, nil, 0);
for i:=0 to c-1 do
begin
buffer[0] := #0;
DragQueryFile(f, i, buffer, SizeOf(buffer));
oSL.Add(buffer);
end;
end;
Clipboard.Close;
Result:=???????
end;