procedure TForm1.moveClick(Sender: TObject);
//移动c:\sybase目录下所有文件到d:\sybase目录下
var
sourcefile,destinationfile:STRING;
lpfileop:TSHFILEOPSTRUCT;
begin
sourcefile:= 'c:\sybase\*.*'+#0#0;
destinationfile:= 'd:\sybase'+#0#0;
fillchar(lpfileop,sizeof(lpfileop),0);
with lpfileop do
begin
wnd:=form1.handle;
wFunc:=FO_MOVE;
pFrom:=pchar(sourcefile);
pTo:=pchar(destinationfile);
fflags:= FOF_NOCONFIRMATION or FOF_NOCONFIRMMKDIR;
end;
if SHFileOperation(lpfileop)<>NOERROR then
if lpfileop. FAnyOperationsAborted then
showmessage('移动文件被终止')
else
showmessage('移动文件出错');
LPCTSTR lpExistingFileName, // address of name of the existing file
LPCTSTR lpNewFileName // address of new name for the file
);
BOOL CopyFile(
LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);