typedef struct _SHFILEOPSTRUCT { // shfos
HWND hwnd;
UINT wFunc;
LPCSTR pFrom;
LPCSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCSTR lpszProgressTitle;
} SHFILEOPSTRUCT, FAR *LPSHFILEOPSTRUCT; var ss: SHFileOpStruct;ss.wFunc := FO_COPY;
.....SHFileOperation(ss);
具体看帮助!
HWND hwnd;
UINT wFunc;
LPCSTR pFrom;
LPCSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCSTR lpszProgressTitle;
} SHFILEOPSTRUCT, FAR *LPSHFILEOPSTRUCT; var ss: SHFileOpStruct;ss.wFunc := FO_COPY;
.....SHFileOperation(ss);
具体看帮助!
值用过SHBrowseForFolder
procedure CopyDirectoryTree(AHandle: THandle; AFromDir,
AToDir: string);
var
SHFileOpStruct:TSHFileOpStruct;
FromDir,ToDir:PChar;
begin
GetMem(FromDir,Length(AFromDir)+2);
try
GetMem(ToDir,Length(AToDir)+2);
try
FillChar(FromDir^,Length(AFromDir)+2,0);
FillChar(ToDir^,Length(AToDir)+2,0);
StrCopy(FromDir,PChar(AFromDir));
StrCopy(ToDir,PChar(AToDir));
with SHFileOpStruct do
begin
Wnd:=AHandle;
wFunc:=FO_COPY;
pFrom:=PChar(AFromDir);
pTo:=PChar(AToDir);
fFlags:=FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
fAnyOperationsAborted:=False;
hNameMappings:=nil;
lpszProgressTitle:=nil;
end;
if SHFileOperation(SHFileOpStruct)<>0 then
RaiseLastWin32Error;
finally
FreeMem(ToDir,Length(AToDir)+2);
end;
finally
FreeMem(FromDir,Length(AFromDir)+2);
end;
end;