Copy Hook Handler Interface: ICopyHook

Now that we are somewhat familiar with copy hook handlers, let’s talk about ICopyHook. This interface is the only interface a copy hook handler needs to implement. It contains one method, CopyCallback. Don’t let the simplicity fool you, though. Implementing a copy hook handler is much more difficult than it seems at first glance (as you will soon see). As Table 9.1 shows, ICopyHook contains one method called CopyCallback. This is the only method ever called on a copy hook handler.

Table 9-1. ICopyHook

Method

Description

CopyCallback

Determines whether the shell will be allowed to move, copy, delete, or rename a folder or printer object.

The syntax of the CopyCallback method is as follows:

UINT CopyCallback(
    HWNDhwnd,
    UINT wFunc,
    UINT wFlags,
    LPCSTR pszSrcFile,
    DWORD dwSrcAttribs,
    LPCSTR pszDestFile,
    DWORD dwDestAttribs
   );

Table 9.2 lists the parameters that the shell passes to the copy hook handler and their meaning.

Table 9-2. CopyCallback Parameters

Parameter

Datatype

Description

hwnd

HWND

Handle to a window that the copy hook handler should use to display any user-interface elements.

wFunc

UINT

Operation to be performed (see Table 9.3).

wFlags

UINT

This value can be ignored for copy hook handlers.

pszSrcFile

LPCSTR/LPCWSTR

Address of a string that contains the name of the source folder or printer.

dwSrcAttribs

DWORD

Attributes of the source folder or printer (see Table 9.3).

pszDestFile

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.