Copy Hook Handlers

Windows 95 calls a copy hook handler before a folder object is moved, copied, deleted, or renamed. You can create a copy hook handler to provide approval or disapproval of a given action. The handler itself does not actually perform the task; the system does that after it receives approval from the copy hook handler. You cannot use a copy hook handler to monitor an action, such as a copying operation, because the handler is not informed of the success or failure of the action.

Like other user interface extensions, copy hook handlers are registered in the Registry. A folder object can have multiple copy hook handlers. A copy hook handler is registered under the directory\shellex\CopyHookHandlers key. Here is a copy hook handler registered in the SHELLEXT sample:

[HKEY_CLASSES_ROOT\directory\shellex\CopyHookHandlers\GAKsCopyHook]
@="{87b9bd00-c65c-11cd-a259-00dd010e8c28}"
[HKEY_CLASSES_ROOT\*\shellex\CopyHookHandlers\GAKsCopyHook]
@="{87b9bd00-c65c-11cd-a259-00dd010e8c28}"

Copy hook handlers differ from other user interface extensions in that the copy hook handler interface is initialized directly—that is, without using an IShellExtInit or IPersistFile interface first. Because of this, you don't need to implement these interfaces. (Hooray! Less work!) You must, however, implement the ICopyHook interface. But this is easily done; you need to implement only the standard IUnknown member functions and ICopyHook's one function, CopyCallBack.

CopyCallBack

The system calls the CopyCallBack member function before it copies, moves, renames, or deletes a folder object. The operation is designated by the wFunc parameter as one of the following:

FO_COPY Copies files in pszSrcFile to pszDestFile
FO_MOVE Moves files in pszSrcFile to pszDestFile
FO_RENAME Renames files in pszSrcFile
FO_DELETE Deletes files in pszSrcFile

This function returns an integer value (IDYES or IDNO) that indicates whether the system should perform the operation. The system calls each copy hook handler registered for a folder object until all the handlers have been called or until a handler returns IDCANCEL.