Platform SDK: Files and I/O

CopyProgressRoutine

The CopyProgressRoutine function is an application-defined callback function used with the CopyFileEx and MoveFileWithProgress functions. It is called when a portion of a copy or move operation is completed. The LPPROGRESS_ROUTINE type defines a pointer to this callback function. CopyProgresRoutine is a placeholder for the application-defined function name.

DWORD CALLBACK CopyProgressRoutine(
  LARGE_INTEGER TotalFileSize,          // file size
  LARGE_INTEGER TotalBytesTransferred,  // bytes transferred
  LARGE_INTEGER StreamSize,             // bytes in stream
  LARGE_INTEGER StreamBytesTransferred, // bytes transferred for stream
  DWORD dwStreamNumber,                 // current stream
  DWORD dwCallbackReason,               // callback reason
  HANDLE hSourceFile,                   // handle to source file
  HANDLE hDestinationFile,              // handle to destination file
  LPVOID lpData                         // from CopyFileEx
);

Parameters

TotalFileSize
[in] Specifies the total size of the file, in bytes.
TotalBytesTransferred
[in] Specifies the total number of bytes transferred from the source file to the destination file since the copy operation began.
StreamSize
[in] Specifies the total size of the current file stream, in bytes.
StreamBytesTransferred
[in] Specifies the total number of bytes in the current stream that have been transferred from the source file to the destination file since the copy operation began.
dwStreamNumber
[in] Handle to the current stream. The stream number is 1 the first time CopyProgressRoutine is called.
dwCallbackReason
[in] Specifies the reason that CopyProgressRoutine was called. This parameter can be one of the following values.
Value Meaning
CALLBACK_CHUNK_FINISHED Another part of the data file was copied.
CALLBACK_STREAM_SWITCH Another stream was created and is about to be copied. This is the callback reason given when the callback routine is first invoked.

hSourceFile
[in] Handle to the source file.
hDestinationFile
[in] Handle to the destination file
lpData
[in] The argument passed to CopyProgressRoutine by the CopyFileEx or MoveFileWithProgress function.

Return Values

The CopyProgressRoutine function should return one of the following values.

Value Meaning
PROGRESS_CONTINUE Continue the copy operation.
PROGRESS_CANCEL Cancel the copy operation and delete the destination file.
PROGRESS_STOP Stop the copy operation. It can be restarted at a later time.
PROGRESS_QUIET Continue the copy operation, but stop invoking CopyProgressRoutine to report progress.

Remarks

An application can use this information to display a progress bar that shows the total number of bytes copied as a percent of the total file size.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Windows 95/98: Unsupported.
  Header: Declared in Winbase.h; include Windows.h.

See Also

File I/O Overview, File I/O Functions, CopyFileEx, MoveFileWithProgress