SHFileOperation函数 问题(100分)

  • 主题发起人 主题发起人 程胜
  • 开始时间 开始时间

程胜

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么样利用SHFileOperation函数 <br>实现删除一个文件目录下的所有文件 而不删除它下面的子目录
 
大概只有DeleteFile才可以!一个个删除而不删除子文件夹下的文件!
 
调试通过:<br><br>uses<br>&nbsp; ShellAPI;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; myrec:TSHFILEOPSTRUCT ;<br>begin<br>&nbsp; with myrec do<br>&nbsp; begin<br>&nbsp; &nbsp; Wnd:= Handle;<br>&nbsp; &nbsp; wFunc:= FO_DELETE;<br>&nbsp; &nbsp; pFrom:= 'd:/tmp/*.*';<br>&nbsp; &nbsp; pTo:='';<br>&nbsp; &nbsp; fFlags:= FOF_NOCONFIRMATION &nbsp;or FOF_FILESONLY;<br>&nbsp; &nbsp; fAnyOperationsAborted:= False;<br>&nbsp; &nbsp; hNameMappings:= Nil;<br>&nbsp; &nbsp; lpszProgressTitle:= Nil;<br>&nbsp; end;<br>&nbsp; SHFileOperation(myrec);<br>end;
 
后退
顶部