您的位置:首页 > 编程语言 > Delphi

Delphi -- 从剪贴板拷贝文件示例代码

2011-03-09 23:57 411 查看
uses Windows, Clipbrd, ShellAPI ....;

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
OpenClipboard(0);
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:ShowMessage('Copy');
DROPEFFECT_MOVE:ShowMessage('Move');
end;
FileCount:=DragQueryFile(DropHandle,Cardinal(-1),nil,0);
for Counter := 0 to FileCount-1 do
begin
DragQueryFile(DropHandle, Counter, FileName, sizeof(FileName));
ShowMessage(FileName);
end;
end;
CloseClipboard;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: