O'Reilly logo

VB Shell Programming by J.P. Hamilton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required