Implementing ICopyHook
Before we begin implementation of
ICopyHook, we need to add a new class to the RadEx
project called clsCopyHook. The class
needs to implement both ICopyHookA and
ICopyHookW:
'clsCopyHook.cls Implements ICopyHookA Implements ICopyHookW
Also, the address of CopyCallback for both
versions of ICopyHook will need to be swapped out
in the vtable. We have to do this because
CopyCallback will need to return one of three
values: IDYES, IDNO, or
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 SubThe preceding code is something we’ve seen before.
All that remains now (this is a lie, of course) is to implement
CopyCallbackA and
CopyCallbackW. For now, our copy hook handler will
do nothing but display a message box that says “Access
Denied” and then it will return IDNO. Later,
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access