网站首页  词典首页

请输入您要查询的函数:

 

术语 copyfileex
释义 CopyFileEx
语法:
C++
BOOL WINAPI CopyFileEx(
__in LPCTSTR lpExistingFileName,
__in LPCTSTR lpNewFileName,
__in_opt LPPROGRESS_ROUTINE lpProgressRoutine,
__in_opt LPVOID lpData,
__in_opt LPBOOL pbCancel,
__in DWORD dwCopyFlags
);
CopyFileEx功能
现有文件的副本到一个新的文件,通知通过一个回调函数,其进步的应用。
作为一个要执行此操作的事务操作,请使用CopyFileTransacted功能。
参数
lpExistingFileName [in]
在现有的文件名。
在此函数的ANSI版本,名称被限制为MAX_PATH字符。为了延长此限制,以32,767宽字符,调用的功能和前面加上“\\ Unicode版本\\?\\”的路径。有关更多信息,请参见命名一个文件。
如果lpExistingFileName不存在,CopyFileEx函数失败,并且GetLastError函数返回ERROR_FILE_NOT_FOUND。
lpNewFileName [in]
新文件的名称。
在此函数的ANSI版本,名称被限制为MAX_PATH字符。为了延长此限制,以32,767宽字符,调用的功能和前面加上“\\ Unicode版本\\?\\”的路径。有关更多信息,请参见命名一个文件。
lpProgressRoutine [中,可选]
该类型的回调函数LPPROGRESS_ROUTINE被称为每次另一个文件的一部分地址已被复制。此参数可以为NULL。欲了解更多的进展回调函数的详细信息,请参阅CopyProgressRoutine功能。
lpData [中,可选]
该参数传递给回调函数。此参数可以为NULL。
pbCancel [中,可选]
如果此标志设置在复制操作为TRUE,则取消操作。否则,复制操作将继续完成。
dwCopyFlags [in]
标志指定该文件是如何被拷贝。此参数可以是下列值的组合。
ValueMeaning
COPY_FILE_ALLOW_DECRYPTED_DESTINATION
0x00000008An试图加密的文件复制成功,即使目标副本不能被加密。
Windows 2000中:此值不支持。
COPY_FILE_COPY_SYMLINK
0x00000800If源文件是一个符号链接,目标文件也是一个符号链接指向同一个文件,源符号链接指向。
Windows Server 2003和Windows XP/2000操作系统:此值不支持。
COPY_FILE_FAIL_IF_EXISTS
0x00000001The立即复制操作失败,如果目标文件已经存在。
COPY_FILE_NO_BUFFERING
0x00001000The复制操作是使用缓冲I / O,绕过系统I / O缓存的资源。建议非常大的文件传输。
Windows Server 2003和Windows XP/2000操作系统:此值不支持。
COPY_FILE_OPEN_SOURCE_FOR_WRITE
0x00000004The文件复制和原始文件进行写访问打开。
COPY_FILE_RESTARTABLE
副本0x00000002Progress跟踪的情况下,在目标文件复制失败。失败的副本可以重新启动了通过指定lpExistingFileName和失败中所使用的lpNewFileName调用相同的值以后。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多的错误信息,调用GetLastError函数。
如果lpProgressRoutine返回PROGRESS_CANCEL由于用户取消操作,CopyFileEx将返回零,而且GetLastError将返回ERROR_REQUEST_ABORTED。在这种情况下,部分复制的目标文件被删除。
如果lpProgressRoutine返回PROGRESS_STOP由于用户停止操作,CopyFileEx将返回零,而且GetLastError将返回ERROR_REQUEST_ABORTED。在这种情况下,部分复制的目标文件保持不变。
备注
此功能保留扩展属性,OLE结构化存储,NTFS文件系统备用数据流,文件属性。安全属性不会复制到新的文件现有的文件。要复制安全属性,使用SHFileOperation函数。
此功能与ERROR_ACCESS_DENIED失败如果目标文件已经存在,并有FILE_ATTRIBUTE_HIDDEN或FILE_ATTRIBUTE_READONLY属性。
当加密的文件复制使用CopyFileEx,函数试图加密与源文件加密使用的密钥目标文件。如果不能这样做,这个函数试图使用默认加密密钥目标文件。如果这些方法都不能这样做,CopyFileEx失败并ERROR_ENCRYPTION_FAILED错误代码。如果您想CopyFileEx完成复制操作,即使目标文件不能被加密,包括作为dwCopyFlags参数在您的电话的价值CopyFileEx COPY_FILE_ALLOW_DECRYPTED_DESTINATION。
Windows 2000的:当加密文件复制使用CopyFileEx,函数试图加密使用默认密钥目标文件。任何试图将加密与源文件加密使用的密钥目标文件。如果它不能被加密,加密CopyFileEx没有完成目标文件的复制操作。
如果COPY_FILE_COPY_SYMLINK指定,适用下列规则:
如果源文件是一个符号链接,复制符号链接,而不是目标文件。
如果源文件不是一个符号链接,没有任何行为的改变。
如果目标文件是现有的符号链接,符号链接被覆盖,而不是目标文件。
如果COPY_FILE_FAIL_IF_EXISTS还明确,目标文件是现有的符号链接,则操作将失败的所有情况。
如果没有指定COPY_FILE_COPY_SYMLINK,适用下列规则:
如果COPY_FILE_FAIL_IF_EXISTS还明确,目标文件是现有的符号链接,只要操作失败的符号链接的目标存在。
如果没有指定COPY_FILE_FAIL_IF_EXISTS,没有任何行为的改变。
如果您正在编写一个应用程序,优化文件通过LAN复制操作,可以考虑使用从Windows套接字(Winsock)的TransmitFile函数。 TransmitFile支持高性能的网络传输,并提供一个简单的接口发送一个文件的内容到远程计算机。要使用TransmitFile,您必须编写一个Winsock客户端应用程序发送从源计算机以及一个Winsock服务器的应用程序,使用其他Winsock函数来获得远程计算机上的文件。
要编译的应用程序使用此函数,定义为0x0400或更高_WIN32_WINNT宏。有关详细信息,请参阅使用Windows头。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesCopyFileExW(Unicode)和CopyFileExA(ANSI)的
参见
CopyFile
CopyFileTransacted
CopyProgressRoutine
CreateFile
文件属性
文件管理函数
MoveFile
MoveFileWithProgress
符号链接
TransmitFile
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==CopyFileEx Function
Copies an existing file to a new file, notifying the application of its progress through a callback function.
To perform this operation as a transacted operation, use the CopyFileTransacted function.
Syntax
C++
BOOL WINAPI CopyFileEx(
__in LPCTSTR lpExistingFileName,
__in LPCTSTR lpNewFileName,
__in_opt LPPROGRESS_ROUTINE lpProgressRoutine,
__in_opt LPVOID lpData,
__in_opt LPBOOL pbCancel,
__in DWORD dwCopyFlags
);
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, the CopyFileEx function fails, and the GetLastError function 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 .
lpProgressRoutine [in, optional]
The address of a callback function of type LPPROGRESS_ROUTINE that is called each time another portion of the file has been copied. This parameter can be NULL. For more information on the progress callback function, see the CopyProgressRoutine function.
lpData [in, optional]
The argument to be passed to the callback function. This parameter can be NULL.
pbCancel [in, optional]
If this flag is set to TRUE during the copy operation, the operation is canceled. Otherwise, the copy operation will continue to completion.
dwCopyFlags [in]
Flags that specify how the file is to be copied. This parameter can be a combination of the following values.
ValueMeaning
COPY_FILE_ALLOW_DECRYPTED_DESTINATION
0x00000008An attempt to copy an encrypted file will succeed even if the destination copy cannot be encrypted.
Windows 2000: This value is not supported.
COPY_FILE_COPY_SYMLINK
0x00000800If the source file is a symbolic link, the destination file is also a symbolic link pointing to the same file that the source symbolic link is pointing to.
Windows Server 2003 and Windows XP/2000: This value is not supported.
COPY_FILE_FAIL_IF_EXISTS
0x00000001The copy operation fails immediately if the target file already exists.
COPY_FILE_NO_BUFFERING
0x00001000The copy operation is performed using unbuffered I/O, bypassing system I/O cache resources. Recommended for very large file transfers.
Windows Server 2003 and Windows XP/2000: This value is not supported.
COPY_FILE_OPEN_SOURCE_FOR_WRITE
0x00000004The file is copied and the original file is opened for write access.
COPY_FILE_RESTARTABLE
0x00000002Progress of the copy is tracked in the target file in case the copy fails. The failed copy can be restarted at a later time by specifying the same values for lpExistingFileName and lpNewFileName as those used in the call that failed.

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.
If lpProgressRoutine returns PROGRESS_CANCEL due to the user canceling the operation, CopyFileEx will return zero and GetLastError will return ERROR_REQUEST_ABORTED. In this case, the partially copied destination file is deleted.
If lpProgressRoutine returns PROGRESS_STOP due to the user stopping the operation, CopyFileEx will return zero and GetLastError will return ERROR_REQUEST_ABORTED. In this case, the partially copied destination file is left intact.
Remarks
This function preserves extended attributes, OLE structured storage, NTFS file system alternate data streams, and file attributes. Security attributes for the existing file are not copied to the new file. To copy security attributes, use the SHFileOperation function.
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 encrypted files are copied using CopyFileEx, the function 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. If both of these methods cannot be done, CopyFileEx fails with an ERROR_ENCRYPTION_FAILED error code. If you want CopyFileEx to complete the copy operation even if the destination file cannot be encrypted, include the COPY_FILE_ALLOW_DECRYPTED_DESTINATION as the value of the dwCopyFlags parameter in your call to CopyFileEx.
Windows 2000: When encrypted files are copied using CopyFileEx, 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, CopyFileEx completes the copy operation without encrypting the destination file.
If COPY_FILE_COPY_SYMLINK is specified, the following rules apply:
If the source file is a symbolic link, the symbolic link is copied, not the target file.
If the source file is not a symbolic link, there is no change in behavior.
If the destination file is an existing symbolic link, the symbolic link is overwritten, not the target file.
If COPY_FILE_FAIL_IF_EXISTS is also specified, and the destination file is an existing symbolic link, the operation fails in all cases.
If COPY_FILE_COPY_SYMLINK is not specified, the following rules apply:
If COPY_FILE_FAIL_IF_EXISTS is also specified, and the destination file is an existing symbolic link, the operation fails only if the target of the symbolic link exists.
If COPY_FILE_FAIL_IF_EXISTS is not specified, there is no change in behavior.
If you are writing an application that is optimizing file copy operations across a LAN, consider using the TransmitFile function from Windows Sockets (Winsock). TransmitFile supports high-performance network transfers and provides a simple interface to send the contents of a file to a remote computer. To use TransmitFile, you must write a Winsock client application that sends the file from the source computer as well as a Winsock server application that uses other Winsock functions to receive the file on the remote computer.
To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0400 or later. For more information, see Using the Windows Headers .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesCopyFileExW (Unicode) and CopyFileExA (ANSI)
See Also
CopyFile
CopyFileTransacted
CopyProgressRoutine
CreateFile
File Attributes
File Management Functions
MoveFile
MoveFileWithProgress
Symbolic Links
TransmitFile
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa363852(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 更新时间:2025/1/8 10:51:46