only for RuBoard - do not distribute or recompile |
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.
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.
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. |
Name | Description |
---|---|
FO_COPY | Copy |
FO_MOVE | Move |
FO_DELETE | Delete |
FO_RENAME | Rename |
CopyCallback can return one of three values:
The operation is allowed.
Prevents the operation on this folder. The shell can continue with any other operations that are pending.
Prevents the current operation and cancels all pending operations.
The IDL listing for both ICopyHookA and ICopyHookW is shown in Example 9.1.
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 |