Dim oICopyHookA As ICopyHookA Set oICopyHookA = Me m_lpOldFuncA = ReplaceVTableEntry(ObjPtr(oICopyHookA), 4, VarPtr(g_abCodesA(0)))
Dim oICopyHookW As ICopyHookW Set oICopyHookW = Me m_lpOldFuncW = ReplaceVTableEntry(ObjPtr(oICopyHookW), 4, VarPtr(g_abCodesW(0))) End SubPrivate Sub ICopyHookA_CopyCallback(ByVal hwnd As Long, ByVal wFunc As Long, ByVal wFlags As Long, ByVal pszSrcFile As Long, ByVal dwSrcAttribs As Long, ByVal pszDestFile As Long, ByVal dwDestAttribs As Long) 'Ansi Version End Sub
看看标准答案: ' This function should be called by any app that changes anything in the shell. ' The shell will then notify each "notification registered" window of this action. Declare Sub SHChangeNotify Lib "shell32" _ (ByVal wEventId As SHCN_EventIDs, _ ByVal uFlags As SHCN_ItemFlags, _ ByVal dwItem1 As Long, _ ByVal dwItem2 As Long)' Shell notification event IDsPublic Enum SHCN_EventIDs SHCNE_RENAMEITEM = &H1 ' (D) A nonfolder item has been renamed. SHCNE_CREATE = &H2 ' (D) A nonfolder item has been created. SHCNE_DELETE = &H4 ' (D) A nonfolder item has been deleted. SHCNE_MKDIR = &H8 ' (D) A folder item has been created. SHCNE_RMDIR = &H10 ' (D) A folder item has been removed. SHCNE_MEDIAINSERTED = &H20 ' (G) Storage media has been inserted into a drive. SHCNE_MEDIAREMOVED = &H40 ' (G) Storage media has been removed from a drive. SHCNE_DRIVEREMOVED = &H80 ' (G) A drive has been removed. SHCNE_DRIVEADD = &H100 ' (G) A drive has been added. SHCNE_NETSHARE = &H200 ' A folder on the local computer is being shared via the network. SHCNE_NETUNSHARE = &H400 ' A folder on the local computer is no longer being shared via the network. SHCNE_ATTRIBUTES = &H800 ' (D) The attributes of an item or folder have changed. SHCNE_UPDATEDIR = &H1000 ' (D) The contents of an existing folder have changed, but the folder still exists and has not been renamed. SHCNE_UPDATEITEM = &H2000 ' (D) An existing nonfolder item has changed, but the item still exists and has not been renamed. SHCNE_SERVERDISCONNECT = &H4000 ' The computer has disconnected from a server. SHCNE_UPDATEIMAGE = &H8000& ' (G) An image in the system image list has changed. SHCNE_DRIVEADDGUI = &H10000 ' (G) A drive has been added and the shell should create a new window for the drive. SHCNE_RENAMEFOLDER = &H20000 ' (D) The name of a folder has changed. SHCNE_FREESPACE = &H40000 ' (G) The amount of free space on a drive has changed.#If (WIN32_IE >= &H400) Then SHCNE_EXTENDED_EVENT = &H4000000 ' (G) Not currently used. #End If ' WIN32_IE >= &H0400 SHCNE_ASSOCCHANGED = &H8000000 ' (G) A file type association has changed. SHCNE_DISKEVENTS = &H2381F ' Specifies a combination of all of the disk event identifiers. (D) SHCNE_GLOBALEVENTS = &HC0581E0 ' Specifies a combination of all of the global event identifiers. (G) SHCNE_ALLEVENTS = &H7FFFFFFF SHCNE_INTERRUPT = &H80000000 ' The specified event occurred as a result of a system interrupt. ' It is stripped out before the clients of SHCNNotify_ see it. End Enum#If (WIN32_IE >= &H400) Then ' ??? Public Const SHCNEE_ORDERCHANGED = &H2 ' dwItem2 is the pidl of the changed folder #End If' Notification flags' uFlags & SHCNF_TYPE is an ID which indicates what dwItem1 and dwItem2 mean Public Enum SHCN_ItemFlags SHCNF_IDLIST = &H0 ' LPITEMIDLIST SHCNF_PATHA = &H1 ' path name SHCNF_PRINTERA = &H2 ' printer friendly name SHCNF_DWORD = &H3 ' DWORD SHCNF_PATHW = &H5 ' path name SHCNF_PRINTERW = &H6 ' printer friendly name SHCNF_TYPE = &HFF ' Flushes the system event buffer. The function does not return until the system is ' finished processing the given event. SHCNF_FLUSH = &H1000 ' Flushes the system event buffer. The function returns immediately regardless of ' whether the system is finished processing the given event. SHCNF_FLUSHNOWAIT = &H2000#If UNICODE Then SHCNF_PATH = SHCNF_PATHW SHCNF_PRINTER = SHCNF_PRINTERW #Else SHCNF_PATH = SHCNF_PATHA SHCNF_PRINTER = SHCNF_PRINTERA #End If End Enum
' 版权所有 (c), 2000 - 2010, 超级绿豆
'
' ************************ 模 块 名 :CVBCopyHook********************
'版 本 号: V1.0
'作 者: 超级绿豆
'生成日期: 2004年06月19日
'最近修改:
'功能描述:
'函数列表:
'修改历史:
'日 期: 2004年06月19日
'修改人员: 超级绿豆
'修改内容: 生成
'******************************************************************************/
'
Option Explicit
'本模块名称
Private Const THIS_MODULE_NAME As String = "CVBCopyHook"Implements ICopyHookA
Implements ICopyHookWPrivate m_lpOldFuncA As Long
Private m_lpOldFuncW As LongPrivate Sub Class_Initialize()
Call PrepareCodes
Dim oICopyHookA As ICopyHookA
Set oICopyHookA = Me
m_lpOldFuncA = ReplaceVTableEntry(ObjPtr(oICopyHookA), 4, VarPtr(g_abCodesA(0)))
Dim oICopyHookW As ICopyHookW
Set oICopyHookW = Me
m_lpOldFuncW = ReplaceVTableEntry(ObjPtr(oICopyHookW), 4, VarPtr(g_abCodesW(0)))
End SubPrivate Sub ICopyHookA_CopyCallback(ByVal hwnd As Long, ByVal wFunc As Long, ByVal wFlags As Long, ByVal pszSrcFile As Long, ByVal dwSrcAttribs As Long, ByVal pszDestFile As Long, ByVal dwDestAttribs As Long)
'Ansi Version
End Sub
' This function should be called by any app that changes anything in the shell.
' The shell will then notify each "notification registered" window of this action.
Declare Sub SHChangeNotify Lib "shell32" _
(ByVal wEventId As SHCN_EventIDs, _
ByVal uFlags As SHCN_ItemFlags, _
ByVal dwItem1 As Long, _
ByVal dwItem2 As Long)' Shell notification event IDsPublic Enum SHCN_EventIDs
SHCNE_RENAMEITEM = &H1 ' (D) A nonfolder item has been renamed.
SHCNE_CREATE = &H2 ' (D) A nonfolder item has been created.
SHCNE_DELETE = &H4 ' (D) A nonfolder item has been deleted.
SHCNE_MKDIR = &H8 ' (D) A folder item has been created.
SHCNE_RMDIR = &H10 ' (D) A folder item has been removed.
SHCNE_MEDIAINSERTED = &H20 ' (G) Storage media has been inserted into a drive.
SHCNE_MEDIAREMOVED = &H40 ' (G) Storage media has been removed from a drive.
SHCNE_DRIVEREMOVED = &H80 ' (G) A drive has been removed.
SHCNE_DRIVEADD = &H100 ' (G) A drive has been added.
SHCNE_NETSHARE = &H200 ' A folder on the local computer is being shared via the network.
SHCNE_NETUNSHARE = &H400 ' A folder on the local computer is no longer being shared via the network.
SHCNE_ATTRIBUTES = &H800 ' (D) The attributes of an item or folder have changed.
SHCNE_UPDATEDIR = &H1000 ' (D) The contents of an existing folder have changed, but the folder still exists and has not been renamed.
SHCNE_UPDATEITEM = &H2000 ' (D) An existing nonfolder item has changed, but the item still exists and has not been renamed.
SHCNE_SERVERDISCONNECT = &H4000 ' The computer has disconnected from a server.
SHCNE_UPDATEIMAGE = &H8000& ' (G) An image in the system image list has changed.
SHCNE_DRIVEADDGUI = &H10000 ' (G) A drive has been added and the shell should create a new window for the drive.
SHCNE_RENAMEFOLDER = &H20000 ' (D) The name of a folder has changed.
SHCNE_FREESPACE = &H40000 ' (G) The amount of free space on a drive has changed.#If (WIN32_IE >= &H400) Then
SHCNE_EXTENDED_EVENT = &H4000000 ' (G) Not currently used.
#End If ' WIN32_IE >= &H0400 SHCNE_ASSOCCHANGED = &H8000000 ' (G) A file type association has changed. SHCNE_DISKEVENTS = &H2381F ' Specifies a combination of all of the disk event identifiers. (D)
SHCNE_GLOBALEVENTS = &HC0581E0 ' Specifies a combination of all of the global event identifiers. (G)
SHCNE_ALLEVENTS = &H7FFFFFFF
SHCNE_INTERRUPT = &H80000000 ' The specified event occurred as a result of a system interrupt.
' It is stripped out before the clients of SHCNNotify_ see it.
End Enum#If (WIN32_IE >= &H400) Then ' ???
Public Const SHCNEE_ORDERCHANGED = &H2 ' dwItem2 is the pidl of the changed folder
#End If' Notification flags' uFlags & SHCNF_TYPE is an ID which indicates what dwItem1 and dwItem2 mean
Public Enum SHCN_ItemFlags
SHCNF_IDLIST = &H0 ' LPITEMIDLIST
SHCNF_PATHA = &H1 ' path name
SHCNF_PRINTERA = &H2 ' printer friendly name
SHCNF_DWORD = &H3 ' DWORD
SHCNF_PATHW = &H5 ' path name
SHCNF_PRINTERW = &H6 ' printer friendly name
SHCNF_TYPE = &HFF
' Flushes the system event buffer. The function does not return until the system is
' finished processing the given event.
SHCNF_FLUSH = &H1000
' Flushes the system event buffer. The function returns immediately regardless of
' whether the system is finished processing the given event.
SHCNF_FLUSHNOWAIT = &H2000#If UNICODE Then
SHCNF_PATH = SHCNF_PATHW
SHCNF_PRINTER = SHCNF_PRINTERW
#Else
SHCNF_PATH = SHCNF_PATHA
SHCNF_PRINTER = SHCNF_PRINTERA
#End If
End Enum