Download demo project - 23 Kb
Download source files - 9 Kb <!-- Article Starts -->
CShellFileOp class is designed to be an easy-to-use wrapper for the Win32
SHFileOperation() API. This function is powerful, but using it requires lots of bookkeeping.
CShellFileOp hides the complex details of the API, and instead lets the programmer use familiar C++ constructs. It also does extensive error-checking of the parameters you use. This decreases headaches, reduces the amount of time the programmer loses wading through the docs, and in general makes everyone happy.
CShellFileOp was written with MSVC 5.0 and tested with 6.0. The sample project is now in 6.0 format. I have also tested it in Unicode on NT 4.
Example - Using CShellFileOp to copy files
Below is example code showing the way
SHFileOperation(). I have included complete documentation for the class in each of the zip files accompanying this article. The docs are in the file
sfo.AddSourceFile ( _T("c:\\windows\\command\\format.com") );
sfo.AddSourceFile ( _T("c:\\windows\\command\\fdisk.exe") );
sfo.AddSourceFile ( _T("c:\\*.com") );
sfo.AddDestFile ( _T("A:\\") );
( FO_COPY, AfxGetMainWnd(), FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE );
if ( sfo.Go ( &bAPICalled, &nAPIReturnVal ) )
if ( !bAPICalled )
October 11, 1998: Version 1.0. First release.
February 27, 2000: Version 1.1. Fixed a bug in
CShellFileOp::Go() that allocated too much memory in Unicode builds.
You can get the latest updates to this and my other articles at http://home.inreach.com/mdunn/code/
Software Developer (Senior)
Michael lives in sunny Mountain View, California. He started programming with an Apple //e
in 4th grade, graduated from UCLA
with a math degree in 1994, and immediately landed a job as a QA engineer at Symantec, working on the Norton AntiVirus team. He pretty much taught himself Windows and MFC programming, and in 1999 he designed and coded a new interface for Norton AntiVirus 2000.
Mike has been a a developer at Napster
and at his own lil' startup, Zabersoft, a development company he co-founded with offices in Los Angeles and Odense, Denmark. Mike is now a senior engineer at VMware
He also enjoys his hobbies of playing pinball, bike riding, photography, and Domion on Friday nights (current favorite combo: Village + double Pirate Ship). He would get his own snooker table too if they weren't so darn big! He is also sad that he's forgotten the languages he's studied: French, Mandarin Chinese, and Japanese.
Mike was a VC MVP
from 2005 to 2009.