Question

I use C++ Builder and SHFileOperation to download an application (its folder) from a network location. WinApi has its own progress bar but i need a custom form with a progress bar.

How can i track the copy progress alone so i can have my own progress bar? A short example will definetely help. thanks.

Was it helpful?

Solution

SHFileOperation does not offer you a means to receive progress callbacks. You can either accept the progress feedback dialog provided by the system, or do without any progress reporting at all.

There is CopyFileEx which supports progress callbacks. But that only caters for copying a single file and not an entire directory.

On Vista and later there is IFileOperation which is the replacement for SHFileOperation. This interface is more capable than SHFileOperation. You can use IFileOperation to copy entire directories, and receive progress notification.

If you need to support XP or earlier then you would need to write your own directory copy routine. You would have to calculate the total size of files to be copied, and then perform each individual file copy with CopyFileEx. You'd receive progress callbacks from CopyFileEx and then turn them into overall progress events for your application to display.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top