9.2 Copy Hook Handler Interface: ICopyHook

only for RuBoard - do not distribute or recompile

9.2 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.

Table9.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(     HWND   hwnd   ,     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.

Table9.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

LPCSTR/LPCWSTR

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

dwDestAttribs

DWORD

Attributes of the source folder or printer. These can be any of the file attribute flags that begin with FILE_ATTRIBUTE_* and are available from the API Viewer.

Table9.3. wFunc Values

Name

Description

FO_COPY

Copy

FO_MOVE

Move

FO_DELETE

Delete

FO_RENAME

Rename

CopyCallback can return one of three values:

IDYES

The operation is allowed.

IDNO

Prevents the operation on this folder. The shell can continue with any other operations that are pending.

IDCANCEL

Prevents the current operation and cancels all pending operations.

The IDL listing for both ICopyHookA and ICopyHookW is shown in Example 9.1.

Example 9.1. ICopyHook Interface
 typedef enum { FO_MOVE   = 0x0001, FO_COPY   = 0x0002, FO_DELETE = 0x0003, FO_RENAME = 0x0004 } FO; [     uuid(000214EF-0000-0000-C000-000000000046),     helpstring("ICopyHookA Interface"),     odl ] interface ICopyHookA : IUnknown {     HRESULT CopyCallback([in] HWND hwnd,                           [in] UINT wFunc,                           [in] UINT wFlags,                           [in] LPCSTRVB pszSrcFile,                           [in] DWORD dwSrcAttribs,                          [in] LPCSTRVB pszDestFile,                           [in] DWORD dwDestAttribs); } [     uuid(000214FC-0000-0000-C000-000000000046),     helpstring("ICopyHookW Interface"),     odl ] interface ICopyHookW : IUnknown {     HRESULT CopyCallback([in] HWND hwnd,                           [in] UINT wFunc,                           [in] UINT wFlags,                           [in] LPCWSTRVB pszSrcFile,   [in] DWORD dwSrcAttribs,                          [in] LPCWSTRVB pszDestFile,                           [in] DWORD dwDestAttribs); } 
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