VC knowledge point record

Source: Internet
Author: User

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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.