Вот функция GetChanges, что использую vb:
- Код: Выделить всё
Public Function GetDirHndl(ByVal PathDir As String) As Long
On Error Resume Next
Dim hDir As Long
If Right(PathDir, 1) <> "\" Then PathDir = PathDir + "\"
hDir = CreateFile(PathDir, FILE_LIST_DIRECTORY, FILE_SHARE_READ + FILE_SHARE_WRITE + FILE_SHARE_DELETE, _
ByVal 0&, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS Or FILE_FLAG_OVERLAPPED, ByVal 0&)
GetDirHndl = hDir
End Function
Public Sub StartWatch()
If (DirHndl = 0) Or (DirHndl = -1) Then Exit Sub
nBufLen = 1024
ReDim cBuffer(0 To nBufLen)
Call ReadDirectoryChangesW(DirHndl, cBuffer(0), nBufLen, WSubFolder, _
FILE_NOTIF_GLOB, nReadLen, 0, 0)
End Sub
Public Function GetChanges() As String
On Error Resume Next
Dim fName As String
MoveMemory fiBuffer.NextEntryOffset, cBuffer(0), 4
MoveMemory fiBuffer.Action, cBuffer(4), 4
MoveMemory fiBuffer.FileNameLength, cBuffer(8), 4
ReDim cBuff2(0 To fiBuffer.FileNameLength)
MoveMemory cBuff2(0), cBuffer(12), fiBuffer.FileNameLength
fiBuffer.FileName = cBuff2
Select Case fiBuffer.Action
Case FILE_ACTION_ADDED
sAction = "Added file"
Case FILE_ACTION_REMOVED
sAction = "Removed file"
Case FILE_ACTION_MODIFIED
sAction = "Modified file"
Case FILE_ACTION_RENAMED_OLD_NAME
sAction = "Renamed from"
Case FILE_ACTION_RENAMED_NEW_NAME
sAction = "Renamed to"
Case Else
sAction = "Unknown"
End Select
fName = sAction + "-" + FolderPath + fiBuffer.FileName
If sAction <> "Unknown" Then GetChanges = fName
End Function
Нашел решение, этой преслаутой задачи, только на С, на самом деле инфа приходит, только нада как-то из буфера вытаскивать инфу. Помогите, как решить это в вышеуказанном коде.
Решение на С/С++