S
starsite
Unregistered / Unconfirmed
GUEST, unregistred user!
XXXXXXXXX--------------又是“剪切板”的问题(关于Copy/Cut文件)!--------------XXXXXXXXX ( 积分: 100 )<br />用 TShellListView 的右键菜单“剪切”文件。然后读取剪切板数据,你会发现,只能取到文件路径,但无法判断是Copy还是Cut! (注:用外部程序判断是正常的,只有在进程内判断又问题!)
期待望高手指点!
读取剪切板的函数如下:
const
DROPEFFECT_COPY = 1; // 复制
DROPEFFECT_MOVE = 2; // 剪切
function GetClipbrdFiles(const fileDirs: TStrings; var dwEffect: Cardinal) : Boolean;
var
f: THandle;
buffer: array [0..MAX_PATH] of Char;
i, numFiles : Integer;
uDropEffect : Cardinal;
begin
Result := false;
if not Clipboard.HasFormat(CF_HDROP) then
begin
Exit;
end;
try
Clipboard.Open();
except
end;
try
f := Clipboard.GetAsHandle(CF_HDROP);
if f <> 0 then
begin
uDropEffect := RegisterClipboardFormat('Preferred DropEffect');
dwEffect := PCardinal(Clipboard.GetAsHandle(uDropEffect))^;
if fileDirs <> nil then
begin
fileDirs.Clear();
numFiles := DragQueryFile(f, $FFFFFFFF, nil, 0);
for i := 0 to numfiles - 1 do
begin
buffer[0] := #0;
DragQueryFile(f, i, buffer, SizeOf(buffer));
fileDirs.Add(buffer);
end;
end;
end;
finally
Clipboard.Close();
end;
Result := (fileDirs.Count > 0);
end;
期待望高手指点!
读取剪切板的函数如下:
const
DROPEFFECT_COPY = 1; // 复制
DROPEFFECT_MOVE = 2; // 剪切
function GetClipbrdFiles(const fileDirs: TStrings; var dwEffect: Cardinal) : Boolean;
var
f: THandle;
buffer: array [0..MAX_PATH] of Char;
i, numFiles : Integer;
uDropEffect : Cardinal;
begin
Result := false;
if not Clipboard.HasFormat(CF_HDROP) then
begin
Exit;
end;
try
Clipboard.Open();
except
end;
try
f := Clipboard.GetAsHandle(CF_HDROP);
if f <> 0 then
begin
uDropEffect := RegisterClipboardFormat('Preferred DropEffect');
dwEffect := PCardinal(Clipboard.GetAsHandle(uDropEffect))^;
if fileDirs <> nil then
begin
fileDirs.Clear();
numFiles := DragQueryFile(f, $FFFFFFFF, nil, 0);
for i := 0 to numfiles - 1 do
begin
buffer[0] := #0;
DragQueryFile(f, i, buffer, SizeOf(buffer));
fileDirs.Add(buffer);
end;
end;
end;
finally
Clipboard.Close();
end;
Result := (fileDirs.Count > 0);
end;