共用方式為


ICopyHook::CopyCallback method

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

Syntax

UINT CopyCallback(
  [in, optional] HWND    hwnd,
                 UINT    wFunc,
                 UINT    wFlags,
  [in]           PCTSTR  pszSrcFile,
                 DWORD   dwSrcAttribs,
  [in, optional] LPCTSTR pszDestFile,
                 DWORD   dwDestAttribs
);

Parameters

hwnd [in, optional]

Type: HWND

A handle to the window that the copy hook handler should use as the parent for any user interface elements the handler may need to display. If FOF_SILENT is specified in wFunc, the method should ignore this parameter.

wFunc

Type: UINT

The operation to perform. This parameter can be one of the values listed under the wFunc member of the SHFILEOPSTRUCT structure.

wFlags

Type: UINT

The flags that control the operation. This parameter can be one or more of the values listed under the fFlags member of the SHFILEOPSTRUCT structure.

For printer copy hooks, this value is one of the following values defined in Shellapi.h.

PO_DELETE

A printer is being deleted. pszSrcFile points to the full path to the specified printer.

PO_RENAME

A printer is being renamed. The pszSrcFile parameter points to the printer's new name. The pszDestFile parameter points to the old name.

PO_PORTCHANGE

Not supported.

PO_REN_PORT

Not supported. Do not use.

pszSrcFile [in]

Type: PCTSTR

A pointer to a string that contains the name of the source folder.

dwSrcAttribs

Type: DWORD

The attributes of the source folder. This parameter can be a combination of any of the file attribute flags (FILE_ATTRIBUTE_*) defined in the Windows header files. See File Attribute Constants.

pszDestFile [in, optional]

Type: LPCTSTR

A pointer to a string that contains the name of the destination folder.

dwDestAttribs

Type: DWORD

The attributes of the destination folder. This parameter can be a combination of any of the file attribute flags (FILE_ATTRIBUTE_*) defined in the Windows header files. See File Attribute Constants.

Return value

Type: UINT

Returns an integer value that indicates whether the Shell should perform the operation. One of the following:

Return code Description
IDYES

Allows the operation.

IDNO

Prevents the operation on this folder but continues with any other operations that have been approved (for example, a batch copy operation).

IDCANCEL

Prevents the current operation and cancels any pending operations.

 

Remarks

The Shell calls each copy hook handler registered for a folder or printer object until all the handlers have been called, or until one of them returns IDNO or IDCANCEL.

Copy hook handlers for folders are registered under the following key.

  HKEY_CLASSES_ROOT
   Directory
      Shellex
         CopyHookHandlers
            your_copyhook
               (Default) = {copyhook CLSID value}

Copy hook handlers for printers are registered under the following key. FakePre-f29856611b71466b9961cc96d1f8ac70-c0c87b08f3c14e4f95a64cce2bfe0232

When this method is called, the Shell initializes the ICopyHook interface directly without using an IShellExtInit interface first.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shlobj.h

DLL

Shell32.dll (version 4.0 or later)

See also

ICopyHook

SHFileOperation