DeleteFile(PChar('c:/good/bad.exe'));
=======================================
//==========删除一个文件夹内的所有文件=============================
procedure TMainFm.delitem(s:string;Sender: TObject);
var OpStruc: TSHFileOpStruct;
frombuf, tobuf: Array [0..128] of Char;
begin
FillChar( frombuf, Sizeof(frombuf), 0 );
FillChar( tobuf, Sizeof(tobuf), 0 );
StrPCopy( frombuf, s );
With OpStruc DO Begin
Wnd:= Handle;
wFunc:= FO_DELETE;
pFrom:= @frombuf;
pTo:=@tobuf;
fFlags:= FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
fAnyOperationsAborted:= False;
hNameMappings:= Nil;
lpszProgressTitle:= Nil;
end;
ShFileOperation( OpStruc );
end;
例:delitem('c:/test',Sender);