Option Explicit
Public Declare Function FindFirstChangeNotification Lib "kernel32" Alias "FindFirstChangeNotificationA" (ByVal
lpPathName As String, ByVal bWatchSubtree As Long, ByVal dwNotifyFilter As Long) As Long
Public Declare Function FindNextChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
Public Declare Function FindCloseChangeNotification Lib "kernel32" (ByVal hChangeHandle As Long) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long)
As Long
Public Const INVALID_HANDLE_VALUE = -1&
Public Const FILE_NOTIFY_CHANGE_DIR_NAME = &H2
Public Const FILE_NOTIFY_CHANGE_FILE_NAME = &H1
Public Const WAIT_FAILED = -1&
Public Const WAIT_OBJECT_0 = 0&
Public Const WAIT_ABANDONED = &H80&
Public Const WAIT_TIMEOUT = &H102&
Public Const API_TRUE = 1&
Public objChangeHandle As Long
' Create the Change Notyfication Object
objChangeHandle = FindFirstChangeNotification("[Путь_к_исследуемой_папке]", API_TRUE, FILE_NOTIFY_CHANGE_DIR_NAME
Or FILE_NOTIFY_CHANGE_FILE_NAME)
If objChangeHandle <> INVALID_HANDLE_VALUE Then
tmrNotif.Enabled = True
End If
Dim retVal As Long
retVal = WaitForSingleObject(objChangeHandle, 1&)
Select Case retVal
Case WAIT_TIMEOUT
' No changes detected
Case WAIT_OBJECT_0
'
' твой код при измененни файловой структуры исследуемой папки
'
FindNextChangeNotification objChangeHandle
End Select
Сейчас этот форум просматривают: Google-бот и гости: 131