网站首页  词典首页

请输入您要查询的函数:

 

术语 replacefile
释义 ReplaceFile
语法:
C++
BOOL WINAPI ReplaceFile(
__in LPCTSTR lpReplacedFileName,
__in LPCTSTR lpReplacementFileName,
__in_opt LPCTSTR lpBackupFileName,
__in DWORD dwReplaceFlags,
__reserved LPVOID lpExclude,
__reserved LPVOID lpReserved
);
ReplaceFile功能
替换一个与另一个文件的文件,以建立一个原始文件的备份副本选项。替换文件假定的替换的文件和身份的名称。
参数
lpReplacedFileName [in]
该文件的名称被替换。
此文件被打开与GENERIC_READ,DELETE和同步访问权限。在共享模式FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE。
调用者必须具有写访问该文件被替换。有关更多信息,请参阅文件安全性和访问权限。
lpReplacementFileName [in]
该文件,它将取代lpReplacedFileName文件名。
该函数尝试打开这个同步,GENERIC_READ,GENERIC_WRITE,删除文件,WRITE_DAC访问权限,以便它可以保存所有属性和ACL。如果失败,该函数试图打开与同步,GENERIC_READ,删除文件,WRITE_DAC访问权限。没有共享模式是指定的。
lpBackupFileName [中,可选]
该文件将作为一个lpReplacedFileName文件的备份副本的名称。如果该参数为NULL,没有备份文件创建。
dwReplaceFlags [in]
更换选择。此参数可以是一个或多个下列值。
ValueMeaning
REPLACEFILE_WRITE_THROUGH
0x00000001Guarantees的信息复制到被替换的文件是刷新在函数返回到磁盘。
REPLACEFILE_IGNORE_MERGE_ERRORS
0x00000002Ignores发生的错误,而合并的信息(如属性和ACL)由被替换文件替换文件。因此,如果您指定此标志,并没有WRITE_DAC访问,函数调用成功,但不保留的ACL。
REPLACEFILE_IGNORE_ACL_ERRORS
0x00000004Ignores时发生错误,从改为合并文件的ACL信息来替换文件。因此,如果您指定此标志,并没有WRITE_DAC访问,函数调用成功,但不保留的ACL。要编译的应用程序使用此值,定义为0x0600或更高_WIN32_WINNT宏。
Windows Server 2003中,Windows XP和Windows 2000 Server和Windows 2000专业版:此值不支持。
lpExclude
保留供将来使用。
lpReserved
保留供将来使用。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。以下是此功能可能的错误代码。
返回代码/ valueDescription
ERROR_UNABLE_TO_MOVE_REPLACEMENT
1176(0x498)更换文件无法重命名。如果lpBackupFileName被指定,更换和替换文件保留其原来的文件名。否则,替换的文件不再存在和替换文件根据其原来的名称存在。
ERROR_UNABLE_TO_MOVE_REPLACEMENT_2
1177(0x499)替换文件无法移动。替换文件仍然存在,在其原来的名字,但是,它继承了该文件是替换文件流和属性。该文件被替换仍然与lpBackupFileName指定的名称存在。
此错误只发生如果lpBackupFileName不为NULL。
ERROR_UNABLE_TO_REMOVE_REPLACED
1175(0x497)所替换的文件不能被删除。更换和替换文件将保持其原始文件名。
如果任何其他错误返回,如ERROR_INVALID_PARAMETER,更换和替换文件将保留他们原有的文件名。在这种情况下,备份文件不存在,而且不能保证替换文件将继承所有的属性和替换的文件流。
备注
该ReplaceFile功能结合在一个单一的功能,几个步骤。应用程序可以调用ReplaceFile,而不是单独的函数调用的数据保存到一个新的文件,重命名原始文件使用一个临时名称,重新命名新的文件具有与原始文件相同的名称,并删除原始文件。另一个优点是,不仅ReplaceFile新的文件复制数据,同时还保留了原始文件的下列属性:
创建时间
短文件名
对象标识符
的DACL
加密
压缩
尚未命名的替换流文件
例如,如果替换文件被加密,但被替换的文件没有加密,生成的文件都没有加密。
由此产生的文件具有相同的文件ID作为替换文件。
备份文件,替换的文件,并替换文件都必须驻留在同一个卷。
删除或重命名一个文件,您必须或者删除的文件的权限或删除父目录儿童权限。如果您设置了所有除删除和删除子和新文件的DACL访问目录中继承,那么您应该能够创建,而不能删除一个文件。但是,您就可以创建一个文件,您将得到所有的访问您在处理返回的时候您创建该文件给您的要求。如果您要求删除您的时间创建的文件权限,可以删除或重命名与该处理,但不与任何其他文件。
要编译的应用程序使用此函数,定义为0x0500或更高_WIN32_WINNT宏。有关详细信息,请参阅使用Windows头。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesReplaceFileW(Unicode)和ReplaceFileA(ANSI)的
参见
CopyFile
CopyFileEx
文件管理函数
MoveFile
MoveFileEx
MoveFileWithProgress
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==ReplaceFile Function
Replaces one file with another file, with the option of creating a backup copy of the original file. The replacement file assumes the name of the replaced file and its identity.
Syntax
C++
BOOL WINAPI ReplaceFile(
__in LPCTSTR lpReplacedFileName,
__in LPCTSTR lpReplacementFileName,
__in_opt LPCTSTR lpBackupFileName,
__in DWORD dwReplaceFlags,
__reserved LPVOID lpExclude,
__reserved LPVOID lpReserved
);
Parameters
lpReplacedFileName [in]
The name of the file to be replaced.
This file is opened with the GENERIC_READ, DELETE, and SYNCHRONIZE access rights. The sharing mode is FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE.
The caller must have write access to the file to be replaced. For more information, see File Security and Access Rights .
lpReplacementFileName [in]
The name of the file that will replace the lpReplacedFileName file.
The function attempts to open this file with the SYNCHRONIZE, GENERIC_READ, GENERIC_WRITE, DELETE, and WRITE_DAC access rights so that it can preserve all attributes and ACLs. If this fails, the function attempts to open the file with the SYNCHRONIZE, GENERIC_READ, DELETE, and WRITE_DAC access rights. No sharing mode is specified.
lpBackupFileName [in, optional]
The name of the file that will serve as a backup copy of the lpReplacedFileName file. If this parameter is NULL, no backup file is created.
dwReplaceFlags [in]
The replacement options. This parameter can be one or more of the following values.
ValueMeaning
REPLACEFILE_WRITE_THROUGH
0x00000001Guarantees that information copied from the replaced file is flushed to disk before the function returns.
REPLACEFILE_IGNORE_MERGE_ERRORS
0x00000002Ignores errors that occur while merging information (such as attributes and ACLs) from the replaced file to the replacement file. Therefore, if you specify this flag and do not have WRITE_DAC access, the function succeeds but the ACLs are not preserved.
REPLACEFILE_IGNORE_ACL_ERRORS
0x00000004Ignores errors that occur while merging ACL information from the replaced file to the replacement file. Therefore, if you specify this flag and do not have WRITE_DAC access, the function succeeds but the ACLs are not preserved. To compile an application that uses this value, define the _WIN32_WINNT macro as 0x0600 or later.
Windows Server 2003, Windows XP, Windows 2000 Server, and Windows 2000 Professional: This value is not supported.

lpExclude
Reserved for future use.
lpReserved
Reserved for future use.
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 . The following are possible error codes for this function.
Return code/valueDescription
ERROR_UNABLE_TO_MOVE_REPLACEMENT
1176 (0x498)The replacement file could not be renamed. If lpBackupFileName was specified, the replaced and replacement files retain their original file names. Otherwise, the replaced file no longer exists and the replacement file exists under its original name.
ERROR_UNABLE_TO_MOVE_REPLACEMENT_2
1177 (0x499)The replacement file could not be moved. The replacement file still exists under its original name; however, it has inherited the file streams and attributes from the file it is replacing. The file to be replaced still exists with the name specified by lpBackupFileName.
This error only occurs if lpBackupFileName is not NULL.
ERROR_UNABLE_TO_REMOVE_REPLACED
1175 (0x497)The replaced file could not be deleted. The replaced and replacement files retain their original file names.

If any other error is returned, such as ERROR_INVALID_PARAMETER, the replaced and replacement files will retain their original file names. In this scenario, a backup file does not exist and it is not guaranteed that the replacement file will have inherited all of the attributes and streams of the replaced file.
Remarks
The ReplaceFile function combines several steps within a single function. An application can call ReplaceFile instead of calling separate functions to save the data to a new file, rename the original file using a temporary name, rename the new file to have the same name as the original file, and delete the original file. Another advantage is that ReplaceFile not only copies the new file data, but also preserves the following attributes of the original file:
Creation time
Short file name
Object identifier
DACLs
Encryption
Compression
Named streams not already in the replacement file
For example, if the replacement file is encrypted, but the replaced file is not encrypted, the resulting file is not encrypted.
The resulting file has the same file ID as the replacement file.
The backup file, replaced file, and replacement file must all reside on the same volume.
To delete or rename a file, you must have either delete permission on the file or delete child permission in the parent directory. If you set up a directory with all access except delete and delete child and the DACLs of new files are inherited, then you should be able to create a file without being able to delete it. However, you can then create a file, and you will get all the access you request on the handle returned to you at the time you create the file. If you requested delete permission at the time you created the file, you could delete or rename the file with that handle but not with any other.
To compile an application that uses this function, define the _WIN32_WINNT macro as 0x0500 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 namesReplaceFileW (Unicode) and ReplaceFileA (ANSI)
See Also
CopyFile
CopyFileEx
File Management Functions
MoveFile
MoveFileEx
MoveFileWithProgress
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365512(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 13:17:47