大致写了一下没有调试过。<br>procedure _FixedCopyRTL2007; <br>var <br> dFlags: DWORD; <br> sc,s1,s2:string; <br>begin <br> dFlags := MOVEFILE_COPY_ALLOWED or MOVEFILE_REPLACE_EXISTING or MOVEFILE_WRITE_THROUGH; <br><br> s1 := 'c:/'+'rtl2007/rtl'; <br> s2 := 'c:/rtl'; <br> MoveFileEx(PChar(s1), PChar(s2), dFlags); <br>end; <br><br><br>MoveFileEx<br><br>The MoveFileEx function moves an existing file or directory.<br><br>The MoveFileWithProgress function is equivalent to the MoveFileEx function, except that MoveFileWithProgress allows you to provide a callback function that receives progress notifications.<br><br><br>BOOL MoveFileEx(<br> LPCTSTR lpExistingFileName,<br> LPCTSTR lpNewFileName,<br> DWORD dwFlags<br>);<br>Parameters<br>lpExistingFileName <br>[in] A pointer to a null-terminated string that names an existing file or directory on a local computer. <br>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.<br><br>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<br><br>Windows 2000: If you prepend the filename with "//?", you cannot also specify the MOVEFILE_DELAY_UNTIL_REBOOT flag for dwFlags.<br>lpNewFileName <br>[in] A pointer to a null-terminated string that specifies the new name of lpExistingFileName on a local computer. <br>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.<br><br>When moving a directory, the destination must be on the same drive.<br><br>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.<br><br>dwFlags <br>[in] This parameter can be one or more of the following values. Value Meaning <br>MOVEFILE_COPY_ALLOWED If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions. <br>This value cannot be used with MOVEFILE_DELAY_UNTIL_REBOOT.<br> <br>MOVEFILE_CREATE_HARDLINK Reserved for future use. <br>MOVEFILE_DELAY_UNTIL_REBOOT 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. <br>This value can be used only if the process is in the context of a user who belongs to the administrator group or the LocalSystem account.<br><br>This value cannot be used with MOVEFILE_COPY_ALLOWED.<br><br>Windows 2000: If you specify the MOVEFILE_DELAY_UNTIL_REBOOT flag for dwFlags, you cannot also prepend the filename that is specified by lpExistingFileName with "//?". <br>MOVEFILE_FAIL_IF_NOT_TRACKABLE 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.<br>Windows NT: This value is not supported. <br>MOVEFILE_REPLACE_EXISTING If a file named lpNewFileName exists, the function replaces its contents with the contents of the lpExistingFileName file. <br>This value cannot be used if lpNewFileName or lpExistingFileName names a directory. <br> <br>MOVEFILE_WRITE_THROUGH The function does not return until the file is actually moved on the disk. <br>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.<br><br>This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set.<br> <br><br>Return Value<br>If the function succeeds, the return value is nonzero.<br><br>If the function fails, the return value is 0 (zero). To get extended error information, call GetLastError.<br><br>Remarks<br>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:<br><br>HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session Manager/PendingFileRenameOperations<br><br><br>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: <br><br><br>szDstFile/0/0<br><br>or <br><br>szSrcFile/0szDstFile/0<br>The string "szDstFile/0/0" indicates that the file "szDstFile" is to be deleted on reboot. <br><br>The string "szSrcFile/0szDstFile/0" indicates that "szSrcFile" is to be renamed "szDstFile" on reboot.<br><br>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.<br><br>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: