I rewrote this function without reporting the error mentioned above.
class function TMyFun.My_PasteFilesFromClipboard(
out bMoveFiles: Boolean): TArray<String>;
var
DropHandle, DropEffect, Effect : HDROP;
FileCount:Integer;
Counter:Integer;
FileName:array [0..MAX_PATH] of char;
const
DROPEFFECT_NONE = 0;
DROPEFFECT_COPY = 1;
DROPEFFECT_MOVE = 2;
DROPEFFECT_LINK = 4;
DROPEFFECT_SCROLL = $80000000;
begin
Result:=[];
bMoveFiles:=false;
OpenClipboard(0);
Try
DropEffect := RegisterClipboardFormat('Preferred DropEffect');
DropHandle := GetClipboardData(CF_HDROP);
if DropHandle>0 then
begin
Effect := GetClipboardData(DropEffect);
if Effect=0 then Effect := DROPEFFECT_COPY
else Effect := PDWORD(Effect)^;
case Effect of
DROPEFFECT_COPY + DROPEFFECT_LINK:bMoveFiles:=false;
DROPEFFECT_MOVE :bMoveFiles:=TRUE;
end;
FileCount:=DragQueryFile(DropHandle,Cardinal(-1),nil,0);
for Counter := 0 to FileCount-1 do
begin
DragQueryFile(DropHandle, Counter, FileName, sizeof(FileName));
Result:=Result+[FileName];
end;
end;
Finally
CloseClipboard;
End;
end;