GFShellHook/Testfrm.frm
VERSION 5.00
Begin VB.Form Testfrm
Caption = "Form1"
ClientHeight = 3075
ClientLeft = 60
ClientTop = 465
ClientWidth = 4695
LinkTopic = "Form1"
ScaleHeight = 3075
ScaleWidth = 4695
StartUpPosition = 3 'Windows‑Standard
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 435
Left = 60
TabIndex = 2
Top = 60
Visible = 0 'False
Width = 375
End
Begin VB.CommandButton Command2
Caption = "Remove Hook"
Height = 375
Left = 2280
TabIndex = 1
Top = 2640
Width = 2355
End
Begin VB.CommandButton Command1
Caption = "Set Hook"
Height = 375
Left = 2280
TabIndex = 0
Top = 2220
Width = 2355
End
End
Attribute VB_Name = "Testfrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'(c)2002, 2004 by Louis. Sets up a shell hook to receive Shell notification messages.
'
'Downloaded from www.louis‑coder.com.
'Here we have a Shell hook. Call SetSH([any hidden control with a hWnd], [target form])
'to set up the hook. From this time on [target form].GFShellHook_ReceiveEvent() will be
'called when e.g. the user deletes, copies or moves a file within the Windows Shell
'(Explorer, Internet Explorer, etc.). In this way your app can reload file lists to display
'file changes made outside your app. Please look up MSDN for what the messages mean
'in detail (or just try it out).
'
'other
Dim SHEventNumber As Integer
Private Sub Command1_Click()
'on error resume next
Call GFShellHookmod.SetSH(Frame1.hWnd, Me)
End Sub
Private Sub Command2_Click()
'on error resume next
Call GFShellHookmod.RemoveSH
End Sub
Public Sub GFShellHook_ReceiveEvent( _
ByVal SHDescription As String, ByVal SHDrive As String, ByVal SHImageNumber As Integer, _
ByVal SHFirstItemName As String, ByVal SHFirstItemPath As String, _
ByVal SHSecondItemName As String, ByVal SHSecondItemPath As String)
'on error resume next
'
If SHEventNumber = 32767 Then SHEventNumber = 0 'verify
SHEventNumber = SHEventNumber + 1
'
Debug.Print ""
Debug.Print "***EVENT*** #" + LTrim$(Str$(SHEventNumber))
Debug.Print "NAME: " + SHDescription
Debug.Print "DRIVE: " + SHDrive
Debug.Print "IMAGE NUMBER: " + LTrim$(Str$(SHImageNumber))
Debug.Print "FIRST ITEM NAME: " + SHFirstItemName
Debug.Print "FIRST ITEM PATH: " + SHFirstItemPath
Debug.Print "SECOND ITEM NAME: " + SHSecondItemName
Debug.Print "SECOND ITEM PATH: " + SHSecondItemPath
End Sub
Private Sub Form_Unload(Cancel As Integer)
'on error resume next 'remove the hook in any case!
Call GFShellHookmod.RemoveSH
End Sub
[END OF FILE]