我贴的有点问题,重贴一次,,
procedure Tgeren.SpeedButton2Click(Sender: TObject);
VAR
APATH:ANSISTRING;
LPFILEOP:TSHFILEOPSTRUCT;
I,N:INTEGER;
begin
IF CHECKLISTBOX1.Items.Count<>0 THEN
BEGIN
N:=CHECKLISTBOX1.Items.Count;
I:=0;
WHILE I<N DO
BEGIN
IF CHECKLISTBOX1.Checked THEN
BEGIN
APATH:=APATH+CHECKLISTBOX1.Items.Strings+#0;
I:=I+1;
END
ELSE
I:=I+1;
END;
APATH:=APATH+#0;
LPFILEOP.Wnd:=SELF.Handle;
LPFILEOP.wFunc:=FO_DELETE;
LPFILEOP.pFrom:=PCHAR(APATH);
LPFILEOP.pTo:=NIL;
IF CHECKBOX1.Checked=TRUE THEN
LPFILEOP.fFlags:=FOF_NOCONFIRMATION
ELSE
LPFILEOP.fFlags:=FOF_ALLOWUNDO;
LPFILEOP.hNameMappings:=NIL;
LPFILEOP.lpszProgressTitle:=NIL;
LPFILEOP.fAnyOperationsAborted:=TRUE;
IF SHFileOperation(LPFILEOP)=0 THEN
BEGIN
CHECKLISTBOX1.Items.Clear;
PANEL1.Caption:='有'+inttostr(CHECKLISTBOX1.items.count)+'文件选定';
CHECKBOX1.Checked:=FALSE;
END
ELSE
SHOWMESSAGE('删除文件失败!');
END
ELSE
BEGIN
SHOWMESSAGE('没有文件被选定,请选择文件!');
END;
end;