Chapter 9. Copy Hook Handlers
Copy hook handlers are invoked every time a shell folder or printer object is moved, deleted, copied, or renamed. Their sole purpose is either to approve or to disapprove the operation in question. They take no part in the operations themselves, and they don’t care about the results. When one of the aforementioned processes is initiated, the shell provides the name of the source object, the name of the destination object, and the action being performed to the copy hook handler. The handler merely says, “Yeah, go ahead,” or “Stop right there!” That’s it. In fact, the copy hook handler is not even notified of whether the action was successful. It is merely a sentry that stands guard over a particular folder or printer.
Copy hook handlers are a little different from the other shell
extensions we have discussed. First and foremost, they are not
associated with file types, but rather with shell folders and printer
objects. Second, they implement only one interface,
ICopyHook
. If you remember, the previous shell
extensions were first initialized either through
IShellExtInit
or IPersistFile
.
In contrast, copy hook handlers depend on neither interface.
ICopyHook
contains one method,
CopyCallback
, that provides everything the handler
will need, initialization and all. There is another major difference,
but we’ll need to look at the definition for
ICopyHook::CopyCallback
to see
it:
UINT CopyCallback( HWNDhwnd
, UINTwFunc
, UINTwFlags
, LPCSTRpszSrcFile
, DWORD ...
Get VB Shell Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.