Before we begin implementation of
ICopyHook, we need to add a new class to the RadEx
clsCopyHook. The class
needs to implement both
'clsCopyHook.cls Implements ICopyHookA Implements ICopyHookW
Also, the address of
CopyCallback for both
ICopyHook will need to be swapped out
in the vtable. We have to do this because
CopyCallback will need to return one of three
IDCANCEL. This code, which should be very familiar
to you by now, is shown in Example 9.2.
Example 9-2. Class_Initialize Event for Copy Hook Handler
'clsCopyHook.cls Private m_pOldCopyCallbackA As Long Private m_pOldCopyCallbackW As Long Private Sub Class_Initialize( ) Dim pCopyHookA As ICopyHookA Set pCopyHookA = Me m_pOldCopyCallbackA = SwapVtableEntry( _ ObjPtr(pCopyHookA), _ 4, _ AddressOf CopyCallbackA) Dim pCopyHookW As ICopyHookW Set pCopyHookW = Me m_pOldCopyCallbackW = SwapVtableEntry( _ ObjPtr(pCopyHookW), _ 4, _ AddressOf CopyCallbackW) End Sub
The preceding code is something we’ve seen before.
All that remains now (this is a lie, of course) is to implement
CopyCallbackW. For now, our copy hook handler will
do nothing but display a message box that says “Access
Denied” and then it will return
we will reimplement the function to display all of the parameters
passed in by the shell.
Example 9.3 shows our implementation of
CopyCallback. The code is self-explanatory. All it does is display ...