本文整理自网络,侵删。
利用ShellAPI中的函数SHFileOperation,可以将指定的目录删除至回收站。
要使用SHFileOperation 函数,必须用到 SHFILEOPSTRUCT机构,要实现某种功能,就要为该结构赋予相应的值。本例中将目录 c:tepos 移至回收站,主要程序代码如下:
procedure TForm1.Button3Click(Sender: TObject);
var
ass:string;
sop:SHFILEOPSTRUCT;
begin
ass:='C:tepos';
sop.Wnd:=Handle;
sop.wFunc:=FO_DELETE;
sop.pFrom:=PChar(ass);
sop.pTo:='';
sop.fFlags:=FOF_ALLOWUNDO;
SHFileOperation(sop);
end;
SHFILEOperation 函数定义在 ShellApi单元中。
相关阅读 >>
Delphi 解决“richedit line insertion error”错误
更多相关阅读请进入《Delphi》频道 >>