Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Copier;
- uses Windows, SysUtils, ShlObj, mrVic;
- Function CopyFilesFoldersToClipbrd(Paths: String): BOOLEAN; stdcall;
- var
- df: TDropFiles;
- i, iLen, iGlobalSize: Integer;
- hGlb: HGLOBAL;
- pData, Ws: PAnsiChar;
- begin
- Result:= True;
- ZeroMemory(@df,sizeof(df));
- df.pFiles:= sizeof(df);
- df.fWide:= True;
- iLen:= Length(Paths);
- iGlobalSize:= sizeof(df) + iLen*2;
- hGlb:= GlobalAlloc(GMEM_ZEROINIT or GMEM_MOVEABLE or GMEM_DDESHARE,iGlobalSize);
- pData:= PAnsiChar(GlobalLock(hGlb));
- CopyMemory(pData,@df,sizeof(df));
- Ws:= pData + sizeof(df);
- i:= 1;
- while (i <= iLen) do
- begin
- Ws[2*i - 2]:= Paths[i];
- Inc(i);
- end;
- GlobalUnlock(hGlb);
- if (OpenClipboard(0) = False) then
- begin
- VICBox('OpenClipboard::Error');
- Result:= False;
- Exit;
- end;
- EmptyClipboard();
- if (SetClipboardData(CF_HDROP,hGlb) = 0) then
- begin
- VICBox('SetClipboardData::Error');
- Result:= False;
- Exit;
- end;
- if (CloseClipboard = False) then
- begin
- VICBox('CloseClipboard::Error');
- Result:= False;
- Exit;
- end;
- end;
- begin
- try
- if (CopyFilesFoldersToClipbrd('F:\C\A.txt'#0'F:\D'#0'F:\E') = True) then
- VICBox('The file copied to clipboard success!')
- else
- VICBox('The file copied to clipboard not success!');
- except
- DumpExceptionInfomation;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment