9.1 How Copy Hook Handlers Work

only for RuBoard - do not distribute or recompile

9.1 How Copy Hook Handlers Work

A copy hook handler is a system-wide component. Whenever a folder or printer is about to be moved, copied , deleted, or renamed , Explorer looks under the following keys in the registry for any copy hook handlers:

 HKEY_CLASSES_ROOT\     Directory\         shellex\             CopyHookHandlers\ 

and:

 HKEY_CLASSES_ROOT\     Printers\         shellex\             CopyHookHandlers\ 

All registered handlers are called one after the other until every handler has been called or until one of the handlers cancels the operation being performed. The shell loads the component directly and calls ICopyHook::CopyCallback , passing in all the values the handler will need in order to make a decision about the operation in question. These values include such things as the source of the operation (a pathname or printer name ), the destination (where the object is being moved, what it is being renamed, etc.), and the type of operation being performed (moving, deleting, copying, or renaming ).

The copy hook handler takes all of these values into consideration and returns one of three values. It will return IDYES if the operation is allowed, IDNO if it is not allowed, or IDCANCEL to prevent the current operation and cancel any remaining operations.

Because a copy hook handler is global, a few things must be taken into consideration. First, a copy hook handler cannot be associated with a specific folder or printer. It is up to the handler to determine if the operation taking place is of any interest. Second, it is possible to write a copy hook handler that conflicts with another handler. For instance, Handler A tells the shell to ignore the delete operation on the folder c:\source_code . Handler B says that it is okay. Guess who wins? The answer is Handler A. Once an operation has been disallowed , subsequent return values are ignored by the shell.

only for RuBoard - do not distribute or recompile


Visual Basic Shell Programming
Visual Basic Shell Programming
ISBN: B00007FY99
EAN: N/A
Year: 2000
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net