1. The movefilewithprogress function is the same as that of movefileex, except that movefilewithprogress allows you to provide a callback function for receiving mobile progress messages.
MovefileFunction moves an existing file or folder, including its sub-files and folders. It can only be moved under the same directory or volume
MovefileexOrMovefilewithprogressSpecifies how to move a file. It can be moved under different volume, but movefile_copy_allowed must be specified. However, if the movement fails, an error (5) may occur, which is related to the system's read permission.
MovefiletransactedThe operation that allows the transaction to be processed.
# DEFINE _ win32_winnt 0x0500 // compile without this difference
# Include <windows. h>
# Include <stdio. h>
DWORD callback copyprogress (
Large_integer totalfilesize, // total file size, in bytes
Large_integer totalbytestransferred, // total number of bytes transferred
Large_integer streamsize, // total number of bytes for this stream
Large_integer streambytestransferred, // total number of bytes transferred for this stream
DWORD dwstreamnumber, // The current stream
DWORD dwcallbackreason, // reason for callback
Handle hsourcefile, // handle to the source file
Handle hdestinationfile, // handle to the destination file
Lpvoid lpdata // passed by copyfileex
)
{
Static int nrecord = 0;
Nrecord ++;
Printf ("Callback times: % d transmitted: % 08x: % 08x file size: % 08x: % 08x ",
Nrecord,
Totalbytestransferred. highpart,
Totalbytestransferred. lowpart,
Totalfilesize. highpart,
Totalfilesize. lowpart );
Return progress_continue;
}
Int main (INT argc, char * argv [])
{
If (argc! = 3)
{
Printf ("Usage: Command source file target file ");
Return 0;
}
If (! Copyfileex (argv [1], argv [2], (lpprogress_routine) copyprogress, null, false, copy_file_fail_if_exists ))
{
Printf ("copyfileex () failed .");
Return 0;
}
Return 0;
}