With this code you can create a application that watches specified folders. When someone try's to access a folder that is being watched, the
API Declarations
'that was'nt important
'Copy the following in to a module.
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Const NILL = 0&
Const WM_SYSCOMMAND = &H112
Const SC_CLOSE = &HF060
'----------------------------------
Public Sub sFolderGuard(ByVal sWindow As String)
Dim sReadMessage As String
hWndX = FindWindow(vbNullString, sWindow)
sCloseWindow = SendMessage(hWndX, WM_SYSCOMMAND, SC_CLOSE, NILL)
If FindWindow(vbNullString, sWindow) Then
MsgBox "Message",vbCritical,"Title"
Exit Sub
End If
End Sub