网站首页  词典首页

请输入您要查询的函数:

 

术语 copyfile
释义 CopyFile
语法:
C++
BOOL WINAPI CopyFile(
__in LPCTSTR lpExistingFileName,
__in LPCTSTR lpNewFileName,
__in BOOL bFailIfExists
);
CopyFile函数
现有文件的副本到一个新的文件。
该CopyFileEx功能提供了两个额外的功能。 CopyFileEx可以调用指定的回调函数,每一个部分的复制操作完成时间,CopyFileEx能够在复制操作取消。
作为一个要执行此操作的事务操作,请使用CopyFileTransacted功能。
参数
lpExistingFileName [in]
在现有的文件名。
在此函数的ANSI版本,名称被限制为MAX_PATH字符。为了延长此限制,以32,767宽字符,调用的功能和前面加上“\\ Unicode版本\\?\\”的路径。有关更多信息,请参见命名一个文件。
如果lpExistingFileName不存在,CopyFile失败,并且GetLastError返回ERROR_FILE_NOT_FOUND。
lpNewFileName [in]
新文件的名称。
在此函数的ANSI版本,名称被限制为MAX_PATH字符。为了延长此限制,以32,767宽字符,调用的功能和前面加上“\\ Unicode版本\\?\\”的路径。有关更多信息,请参见命名一个文件。
bFailIfExists [in]
如果此参数为true和新的文件已经存在的lpNewFileName指定的函数失败。如果此参数为FALSE,新的文件已存在,该函数将覆盖现有的文件和成功。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
安全属性不会复制到新的文件现有的文件。要复制安全属性,使用SHFileOperation函数。
现有的文件档案属性复制到新的文件。例如,如果一个现有的文件具有FILE_ATTRIBUTE_READONLY文件属性,通过向CopyFile调用创建也将有FILE_ATTRIBUTE_READONLY文件属性的副本。有关更多信息,请参见检索和更改文件属性。
此功能与ERROR_ACCESS_DENIED失败如果目标文件已经存在,并有FILE_ATTRIBUTE_HIDDEN或FILE_ATTRIBUTE_READONLY属性。
当CopyFile是用来加密的文件复制,它试图加密与源文件加密使用的密钥目标文件。如果不能这样做,这个函数试图使用默认加密密钥目标文件,在Windows 2000中。如果这些方法都可以做,CopyFile失败并ERROR_ENCRYPTION_FAILED错误代码。
Windows 2000的:当CopyFile是用来复制加密文件,加密功能,尝试与目标文件默认的钥匙。任何试图将加密与源文件加密使用的密钥目标文件。如果它不能被加密,加密CopyFile没有完成目标文件的复制操作。
符号链接的行为,如果源文件是一个符号链接,实际的文件复制是符号链接的目标。
如果目标文件已经存在,是一个符号链接,符号链接覆盖源文件。
实例
有关示例,请参见检索和更改文件属性。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesCopyFileW(Unicode)和CopyFileA(ANSI)的
参见
CopyFileEx
CopyFileTransacted
CreateFile
文件属性
文件管理函数
MoveFile
符号链接
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==CopyFile Function
Copies an existing file to a new file.
The CopyFileEx function provides two additional capabilities. CopyFileEx can call a specified callback function each time a portion of the copy operation is completed, and CopyFileEx can be canceled during the copy operation.
To perform this operation as a transacted operation, use the CopyFileTransacted function.
Syntax
C++
BOOL WINAPI CopyFile(
__in LPCTSTR lpExistingFileName,
__in LPCTSTR lpNewFileName,
__in BOOL bFailIfExists
);
Parameters
lpExistingFileName [in]
The name of an existing file.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\\\?\\" to the path. For more information, see Naming a File .
If lpExistingFileName does not exist, CopyFile fails, and GetLastError returns ERROR_FILE_NOT_FOUND.
lpNewFileName [in]
The name of the new file.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\\\?\\" to the path. For more information, see Naming a File .
bFailIfExists [in]
If this parameter is TRUE and the new file specified by lpNewFileName already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
Security attributes for the existing file are not copied to the new file. To copy security attributes, use the SHFileOperation function.
File attributes for the existing file are copied to the new file. For example, if an existing file has the FILE_ATTRIBUTE_READONLY file attribute, a copy created through a call to CopyFile will also have the FILE_ATTRIBUTE_READONLY file attribute. For more information, see Retrieving and Changing File Attributes .
This function fails with ERROR_ACCESS_DENIED if the destination file already exists and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_READONLY attribute set.
When CopyFile is used to copy an encrypted file, it attempts to encrypt the destination file with the keys used in the encryption of the source file. If this cannot be done, this function attempts to encrypt the destination file with default keys, as in Windows 2000. If neither of these methods can be done, CopyFile fails with an ERROR_ENCRYPTION_FAILED error code.
Windows 2000: When CopyFile is used to copy an encrypted file, the function attempts to encrypt the destination file with the default keys. No attempt is made to encrypt the destination file with the keys used in the encryption of the source file. If it cannot be encrypted, CopyFile completes the copy operation without encrypting the destination file.
Symbolic link behavior—If the source file is a symbolic link, the actual file copied is the target of the symbolic link.
If the destination file already exists and is a symbolic link, the symbolic link is overwritten by the source file.
Examples
For an example, see Retrieving and Changing File Attributes .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesCopyFileW (Unicode) and CopyFileA (ANSI)
See Also
CopyFileEx
CopyFileTransacted
CreateFile
File Attributes
File Management Functions
MoveFile
Symbolic Links
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa363851(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:30:44