Private Sub HandleDirectoryChanges()
On Error Resume Next

Dim fContinue As Boolean
Dim lPointer As Long, iPos As Integer
Dim lngCompKey As Long
Dim lpOverlapped As OVERLAPPED
Dim fni As FILE_NOTIFY_INFORMATION
Dim DI As DIRECTORY_INFO
Dim FileInfo As FileChange
Dim Add

'// Retrieve the directory info for this directory
'// through the completion key
ret = GetQueuedCompletionStatus(hIOCompPort, _
lpBytesReturned, _
lngCompKey, _
oOverLapped, _
100) '//Put INFINITE if synchronous

If (ret <> 0) Then
lPointer = 0

'//Findout which directory is this based on completionkey
For iPos = 0 To numDirs - 1
If DirInfo(iPos).lComplKey = lngCompKey Then Exit For
Next

Do
FileInfo = GetFileName(DirInfo(iPos).lpBuffer, lPointer)
strPath = Trim(DirInfo(iPos).lpszDirName) & "\" & FileInfo.Name
Select Case FileInfo.Type
Case FILE_ACTION_ADDED
Add = 10
strmsg = "[" & strPath & "] was added to the directory."
Case FILE_ACTION_REMOVED
strmsg = "[" & strPath & "] was removed from the directory."
Case FILE_ACTION_MODIFIED
Add = Add + 1
strmsg = "[" & strPath & "] was modified..."
Case FILE_ACTION_RENAMED_OLD_NAME
strmsg = "[" & strPath & "] was renamed and this is the old name."
Case FILE_ACTION_RENAMED_NEW_NAME
strmsg = "[" & strPath & "] was renamed and this is the new name."
End Select

List2.AddItem strmsg & "Add è = " & Add

lPointer = FileInfo.NextPos

Loop While (lPointer > 0)

ret = ReadDirectoryChangesW(DirInfo(iPos).hDir, _
DirInfo(iPos).lpBuffer(0), _
MAX_BUFFER, _
bWatchSubDir, _
lngFilter, _
lpBytesReturned, _
DirInfo(iPos).oOverLapped, _
ByVal 0&)
End If

End Sub