网站首页  词典首页

请输入您要查询的函数:

 

术语 movefileex
释义 MoveFileEx
语法:
C++
BOOL WINAPI MoveFileEx(
__in LPCTSTR lpExistingFileName,
__in_opt LPCTSTR lpNewFileName,
__in DWORD dwFlags
);
MoveFileEx函数
移动现有的文件或目录,包括儿童,与各种行动方案。
该MoveFileWithProgress功能等同于MoveFileEx功能,除了MoveFileWithProgress使您可以提供一个回调函数,它接收进度通知。
作为一个要执行此操作的事务操作,请使用MoveFileTransacted功能。
参数
lpExistingFileName [in]
该文件或在本地计算机上的目录的当前名称。
如果dwFlags指定MOVEFILE_DELAY_UNTIL_REBOOT,该文件不能存在于远程共享,因为拖延行动之前,网络可用执行。
在此函数的ANSI版本,名称被限制为MAX_PATH字符。为了延长此限制,以32,767宽字符,调用的功能和前面加上“\\ Unicode版本\\?\\”的路径。有关更多信息,请参见命名一个文件
Windows 2000中:如果您前面加上了“\\文件名\\?\\”,您不能同时指定dwFlags MOVEFILE_DELAY_UNTIL_REBOOT标志。
lpNewFileName [中,可选]
该文件或在本地计算机上的目录的新名称。
当移动一个文件,目标可以在不同的文件系统或卷。如果目标是在另一个驱动器,您必须设置在dwFlags的MOVEFILE_COPY_ALLOWED标志。
当移动一个目录,目标必须在同一个驱动器。
如果dwFlags指定MOVEFILE_DELAY_UNTIL_REBOOT和lpNewFileName是NULL,MoveFileEx的lpExistingFileName文件被删除的注册系统重新启动时。如果lpExistingFileName指的是一个目录,系统目录中删除,只有在重新启动该目录是空的。
dwFlags [in]
此参数可以是一个或多个下列值。
ValueMeaning
MOVEFILE_COPY_ALLOWED
2(0x2)如果该文件被移动到一个不同的卷,功能模拟使用CopyFile和DeleteFile函数的做法。
此值不能用于MOVEFILE_DELAY_UNTIL_REBOOT。
MOVEFILE_CREATE_HARDLINK
16(0x10)保留供以后使用。
MOVEFILE_DELAY_UNTIL_REBOOT
4(0x4)系统不动,直到重新启动操作系统的文件。该系统后立即移动Autochk的执行文件,但在建立任何页面文件。因此,此参数使函数删除以前的创业分页文件。
此值才可以使用,如果该进程是在谁的用户属于管理员组或LocalSystem帐户的上下文中。
此值不能用于MOVEFILE_COPY_ALLOWED。
Windows Server 2003和Windows XP中:有关信息,特殊情况下这个功能可能会失败,以及建议的解决方法解决,见文件不交换当Windows Server 2003重新启动,如果您使用MoveFileEx函数来计划在帮助一些文件替换和支持知识库。
Windows 2000中:如果您指定dwFlags MOVEFILE_DELAY_UNTIL_REBOOT标志,您也无法预先准备的文件名称是由lpExistingFileName指定的“\\ \\?”。
MOVEFILE_FAIL_IF_NOT_TRACKABLE
32(0x20)的功能失败如果源文件是一个链接的来源,但文件无法移动后跟踪。出现这种情况如果目标是用FAT文件系统格式化的卷。
MOVEFILE_REPLACE_EXISTING
1(0x1)如果一个文件名为lpNewFileName存在,功能替换的lpExistingFileName文件的内容及其内容,要求提供有关的安全访问控制列表(ACL)得到满足。有关更多信息,请参阅本主题的备注部分。
此值不能使用,如果lpNewFileName或lpExistingFileName名称目录。
MOVEFILE_WRITE_THROUGH
8(0x8)函数不会返回,直到该文件实际上是移动磁盘上。
设置此值,此举为保障和复制执行删除操作刷新到磁盘之前,该函数返回。在刷新发生在复制操作结束。
此值如果MOVEFILE_DELAY_UNTIL_REBOOT没有设置生效。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零(0)。为了获得更多错误信息,调用GetLastError。
备注
如果dwFlags参数指定MOVEFILE_DELAY_UNTIL_REBOOT,MoveFileEx失败如果它不能访问注册表。该功能存储的文件的位置被重新命名为重新启动以下注册表值:
HKEY_LOCAL_MACHINE \\系统\\ CurrentControlSet \\控制\\会话管理器\\删除所提
此注册表值均为REG_MULTI_SZ类型。每个重命名以下空操作商店之一结尾的字符串,具体取决于是否重命名为删除或不:
szDstFile \\ 0 \\ 0
szSrcFile \\ 0szDstFile \\ 0
该字符串szDstFile \\ 0 \\ 0表明该文件szDstFile要在重新启动时删除。该字符串szSrcFile \\ 0szDstFile \\ 0表示szSrcFile更名为在重新启动szDstFile。
注意虽然\\ 0 \\ 0技术上是不允许一个REG_MULTI_SZ节点,它可以因为该文件被认为是重命名为一个空的名称。
该系统使用这些注册表项来完成重新启动的顺序,它们发出的运作。例如,下面的代码片段创建注册表项,删除szDstFile并重新命名szSrcFile将在重新启动szDstFile:
MoveFileEx(szDstFile,空,MOVEFILE_DELAY_UNTIL_REBOOT);
MoveFileEx(szSrcFile,szDstFile,MOVEFILE_DELAY_UNTIL_REBOOT);
因为实际的移动和删除操作与MOVEFILE_DELAY_UNTIL_REBOOT标志指定要调用应用程序后,地方已经停止运行,返回值不能反映成败移动或删除文件。相反,它反映了成功放入注册表中相应的条目或失败。
该系统删除一个是同MOVEFILE_DELAY_UNTIL_REBOOT标志仅当它是空的目录中删除标记。为了确保在试图删除它的目录,移动或删除目录中的所有文件删除。文件可能会在启动时的目录,但必须删除或移动之前,系统可以删除该目录。
在移动和删除操作均在开机的顺序,他们是在调用应用程序指定的时间。要删除目录,在启动时已在它的文件,先删除该文件。
Windows Server 2003和Windows XP中:有关信息,特殊情况下MOVEFILE_DELAY_UNTIL_REBOOT功能可能会失败,以及建议的解决方法解决,见文件不交换当Windows Server 2003重新启动,如果您使用MoveFileEx函数来计划在帮助一些文件替换和支持知识库。
如果在一个文件卷移动,MoveFileEx不会移动的文件的安全描述符。是分配给该文件在目标目录的默认安全描述符。
该MoveFileEx函数协调与跟踪服务环节的运作,使连结来源可以追踪到这些被移动。
删除或重命名一个文件,您必须或者删除的文件的权限或删除父目录儿童权限。如果您设置了所有除删除和删除子和新文件的ACL访问目录中继承,那么您应该能够创建,而不能删除一个文件。但是,您就可以创建一个文件,并获取所有访问您在处理返回的时间,在创建文件给您的要求。如果您要求删除时创建文件的权限,您可以删除或重命名与该处理但没有任何其他处理的文件。有关更多信息,请参阅文件安全性和访问权限。
实例
有关示例,请参见创建和使用临时文件。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesMoveFileExW(Unicode)和MoveFileExA(ANSI)的
参见
CopyFile
的DeleteFile
文件管理函数
文件安全性和访问权限
GetWindowsDirectory
MoveFileTransacted
MoveFileWithProgress
WritePrivateProfileString
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==MoveFileEx Function
Moves an existing file or directory, including its children, with various move options.
The MoveFileWithProgress function is equivalent to the MoveFileEx function, except that MoveFileWithProgress allows you to provide a callback function that receives progress notifications.
To perform this operation as a transacted operation, use the MoveFileTransacted function.
Syntax
C++
BOOL WINAPI MoveFileEx(
__in LPCTSTR lpExistingFileName,
__in_opt LPCTSTR lpNewFileName,
__in DWORD dwFlags
);
Parameters
lpExistingFileName [in]
The current name of the file or directory on the local computer.
If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT, the file cannot exist on a remote share, because delayed operations are performed before the network is available.
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
Windows 2000: If you prepend the file name with "\\\\?\\", you cannot also specify the MOVEFILE_DELAY_UNTIL_REBOOT flag for dwFlags.
lpNewFileName [in, optional]
The new name of the file or directory on the local computer.
When moving a file, the destination can be on a different file system or volume. If the destination is on another drive, you must set the MOVEFILE_COPY_ALLOWED flag in dwFlags.
When moving a directory, the destination must be on the same drive.
If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.
dwFlags [in]
This parameter can be one or more of the following values.
ValueMeaning
MOVEFILE_COPY_ALLOWED
2 (0x2)If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions.
This value cannot be used with MOVEFILE_DELAY_UNTIL_REBOOT.
MOVEFILE_CREATE_HARDLINK
16 (0x10)Reserved for future use.
MOVEFILE_DELAY_UNTIL_REBOOT
4 (0x4)The system does not move the file until the operating system is restarted. The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. Consequently, this parameter enables the function to delete paging files from previous startups.
This value can be used only if the process is in the context of a user who belongs to the administrators group or the LocalSystem account.
This value cannot be used with MOVEFILE_COPY_ALLOWED.
Windows Server 2003 and Windows XP: For information about special situations where this functionality can fail, and a suggested workaround solution, see Files are not exchanged when Windows Server 2003 restarts if you use the MoveFileEx function to schedule a replacement for some files in the Help and Support Knowledge Base.
Windows 2000: If you specify the MOVEFILE_DELAY_UNTIL_REBOOT flag for dwFlags, you cannot also prepend the file name that is specified by lpExistingFileName with "\\\\?".
MOVEFILE_FAIL_IF_NOT_TRACKABLE
32 (0x20)The function fails if the source file is a link source, but the file cannot be tracked after the move. This situation can occur if the destination is a volume formatted with the FAT file system.
MOVEFILE_REPLACE_EXISTING
1 (0x1)If a file named lpNewFileName exists, the function replaces its contents with the contents of the lpExistingFileName file, provided that security requirements regarding access control lists (ACLs) are met. For more information, see the Remarks section of this topic.
This value cannot be used if lpNewFileName or lpExistingFileName names a directory.
MOVEFILE_WRITE_THROUGH
8 (0x8)The function does not return until the file is actually moved on the disk.
Setting this value guarantees that a move performed as a copy and delete operation is flushed to disk before the function returns. The flush occurs at the end of the copy operation.
This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set.

Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero (0). To get extended error information, call GetLastError .
Remarks
If the dwFlags parameter specifies MOVEFILE_DELAY_UNTIL_REBOOT, MoveFileEx fails if it cannot access the registry. The function stores the locations of the files to be renamed at restart in the following registry value:
HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\PendingFileRenameOperations
This registry value is of type REG_MULTI_SZ. Each rename operation stores one of the following NULL-terminated strings, depending on whether the rename is a delete or not:
szDstFile\\0\\0
szSrcFile\\0szDstFile\\0
The string szDstFile\\0\\0 indicates that the file szDstFile is to be deleted on reboot. The string szSrcFile\\0szDstFile\\0 indicates that szSrcFile is to be renamed szDstFile on reboot.
Note Although \\0\\0 is technically not allowed in a REG_MULTI_SZ node, it can because the file is considered to be renamed to a null name.
The system uses these registry entries to complete the operations at restart in the same order that they were issued. For example, the following code fragment creates registry entries that delete szDstFile and rename szSrcFile to be szDstFile at restart:
MoveFileEx(szDstFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);
Because the actual move and deletion operations specified with the MOVEFILE_DELAY_UNTIL_REBOOT flag take place after the calling application has ceased running, the return value cannot reflect success or failure in moving or deleting the file. Rather, it reflects success or failure in placing the appropriate entries into the registry.
The system deletes a directory that is tagged for deletion with the MOVEFILE_DELAY_UNTIL_REBOOT flag only if it is empty. To ensure deletion of directories, move or delete all files from the directory before attempting to delete it. Files may be in the directory at boot time, but they must be deleted or moved before the system can delete the directory.
The move and deletion operations are carried out at boot time in the same order that they are specified in the calling application. To delete a directory that has files in it at boot time, first delete the files.
Windows Server 2003 and Windows XP: For information about special situations where MOVEFILE_DELAY_UNTIL_REBOOT functionality can fail, and a suggested workaround solution, see Files are not exchanged when Windows Server 2003 restarts if you use the MoveFileEx function to schedule a replacement for some files in the Help and Support Knowledge Base.
If a file is moved across volumes, MoveFileEx does not move the security descriptor with the file. The file is assigned the default security descriptor in the destination directory.
The MoveFileEx function coordinates its operation with the link tracking service, so link sources can be tracked as they are moved.
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 ACLs 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 get all the access you request on the handle that is returned to you at the time that you create the file. If you request delete permission at the time you create the file, you can delete or rename the file with that handle but not with any other handle. For more information, see File Security and Access Rights .
Examples
For an example, see Creating and Using a Temporary File .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesMoveFileExW (Unicode) and MoveFileExA (ANSI)
See Also
CopyFile
DeleteFile
File Management Functions
File Security and Access Rights
GetWindowsDirectory
MoveFileTransacted
MoveFileWithProgress
WritePrivateProfileString
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365240(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 9:22:38