CopyFile() 是一个 API 调用:
The CopyFile function copies an existing file to a new 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
);
Parameters
lpExistingFileName
Points to a null-terminated string that specifies the name of an existing file.
lpNewFileName
Points to a null-terminated string that specifies the name of the new file.
bFailIfExists
Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.
在Delphi 代码中,应该改为:
var
lpszSrcFileName: string;
lpszDstFileName: string;
begin
...
CopyFile(PChar(lpszSrcFileName), PChar(lpszDstFileName), False);
//如果不想覆盖现存文件, 则设置最后一个参数为 True;
end;