这个要使用 System("xxxxx");delphi没有你要的这个函数,要么你调用deltree要么你自己写
解决方案 »
- 利用DELPHI中的MSComm控件实现单片机与PC机的串口通信程序该怎么编啊?
- WideString与String的转换 急
- sendmessage能够模拟出按shift点击某控件(如TButton)吗?
- 一个窗体dock进一个panel后,按关闭按钮把窗体关闭,然后再show怎么就不出来呢?
- 请问:如何在窗体中得到名为A10的button,并对它操作
- 有谁知道好一点的stringgrid的控件下载
- socket 接收不定长数据包
- 如何清除ie中输入框的已输入信息
- 微软挺好的~不过也挺讨厌的~
- 菜鸟又有问题了,还是关于注册表的,请多指点。
- 我想建一张paradox的表,但不明白里边几种数据类型的意义,请告知!
- 请大家不要再用ADO+ACCESS了有严重的问题请看!......
unit DeleteFileToRecycleBin_Unit;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, StdCtrls, ShellAPI;type
TForm1 = class(TForm)
OpenDialog1: TOpenDialog;
Edit1: TEdit;
DelToRecycleBin: TButton;
SpeedButton1: TSpeedButton;
procedure SpeedButton1Click(Sender: TObject);
procedure DelToRecycleBinClick(Sender: TObject);
function DelToRecycled(FileName:string):Boolean;
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
if opendialog1.Execute then edit1.Text:=opendialog1.FileName;
end;procedure TForm1.DelToRecycleBinClick(Sender: TObject);
begin
if edit1.text='' then exit;
if not FileExists(edit1.text) then Exit;
if messagedlg('Delete file: '+edit1.text+' to recycle bin',mtconfirmation,[mbyes,mbno],0)=idyes
then if deltorecycled(edit1.text) then messagedlg('Delete file successfully!',mtinformation,[mbok],0);
end;function TForm1.DelToRecycled(FileName: string): Boolean;
var f:tshfileopstruct;
begin
fillchar(f,sizeof(f),#0);
f.Wnd:=application.Handle;
f.wFunc:=FO_DELETE;
f.pFrom:=PChar(filename);
f.pTo:=nil;
f.fAnyOperationsAborted:= False;
f.hNameMappings:= Nil;
f.lpszProgressTitle:= Nil;
f.fFlags:={FOF_SILENT or }FOF_ALLOWUNDO{ or FOF_NOCONFIRMATION};
//不要FOF_ALLOWUNDO,就直接删除,要就到回收站
result:=(shfileoperation(f)=0);
end;end.
shfileoperation在NT下不能用。
删除目录函数 RmDir这是Delphi的内置函数。