cFileOperation 0.1
![]()

SHFileOperation has been superseded by IFileOperation on Windows Vista and above. At least the basic parts of it are easy to access in VB6- showing the standard Windows dialog/progress boxes to Move, Copy, or Delete files. While the class handles it, this function also requires us to bring in the IShellItem interface and its relatives into VB, so take a look at the class module code if you ever wanted to use other functions that required this.
Right now this projects just supports the basic calls to Copy/Move/Delete; look for more options, like customizing actions using the .Advise sink method, in future releases.
Requirements
IFileOperation is only available on Windows Vista and higher; this project will not work on XP.
The included olelib.tlb is an upgrade of the standard one and needs to be added as a reference.
Usage Summary
Using the class is fairly straight forward;
-Add a reference to the upgraded olelib.tlb
-Add the class module to the project and go nuts.
-Sample project included to show how the class is called.
Part 1: The Type Library
The easiest way to go about this, due to the extensive dependency tree, was to start with Eduardo Morcillo's olelib. Everything is too tightly interrelated to have separate projects; the conflicts and hours spent re-doing things would simply be unmanageable. So what I've done is take this excellent work, and add in a number of modern interfaces. Old interfaces are the same; if you already use this file in your projects, you can replace it without making any changes to existing code. There's lots to be done with all the new interfaces I've added, and more projects will be forthcoming.
This project contains, at least for the time being while I await an answer on whether its allowed, the upgraded olelib.tlb and the full source to it. You can compile it yourself with the included mk.bat (if your MKTYPLIB.EXE isn't in the standard folder you'll have to edit it).
Among the interfaces added:
IShellItem
IShellItem2
IShellItemArray
IEnumShellItems
IFileOperation
IPropertyChange
IPropertyChangeArray
IObjectWithPropertyKey
IOperationsProgressDialog
IShellLibrary*
ITaskbarList3*
ITaskbarList4*
IActionProgress*
IShellItemImageFactory*
IThumbnailProvider*
* - Not related to the current project, but look for new projects showing their use soon.
Might be a few more I added a long time ago and forgot about, this update is years in the making.
Add olelib.tlb as a reference to your project.
Part 2 - The Class
Once you've added olelib, you're ready to start using cFileOperation. Since this calls the native methods, everything functions the same as in Explorer, including prompts about overwriting, confirmation deletion, etc. No extra code is needed to handle that.
Here are the currently supported calls:
.ParentWindow - Specify the parent window (e.g. Form1.hWnd) to keep the dialogs on top of it.
.SingleFile - For performing operations on a single file.
.SetFileList - For multiple files, specify an array containing a single full path to a file in each item.
.FileList - Retrieve the current file list.
.DestFolder - The destination folder; don't need to set for Delete.
.Flags - Set flags for the operation; uses the standard FileOperationFlags enum (see below).
.CopyFile - Copies the single file.
.CopyFiles - Copies the file list.
.MoveFile - Moves the single file.
.MoveFiles - Moves the file list.
.DeleteFile - Deletes the single file.
.DeleteFiles - Deletes the file list.
File Operation Flags
See MSDN Description of Flags
Can't put it much better than MSDN.
-------
All bug reports, comments, criticisms, and suggestions welcome.
PLEASE NOTE: I don't have access to multiple test systems; everything works on Win7 x64, and everything should work from Vista through 10, but please let met know if there's an issue.