Re: Как освободить буфер ReadDirectoryChangesW
От: Pavel Dvorkin Россия  
Дата: 22.01.07 14:23
Оценка:
Здравствуйте, sunrizer, Вы писали:

S>Возникла проблема при вызове ReadDirectoryChangesW — после занесения определенного количества событий в массив — события перестают отлавливатся. При динамическом выделении памяти — память занятая под массив не освобождается.


S> FILE_NOTIFY_INFORMATION *fn = new FILE_NOTIFY_INFORMATION[file_cnt];


Вот это вообще ИМХО неверно. См. формат

The FILE_NOTIFY_INFORMATION structure describes the changes found by the ReadDirectoryChangesW function.

typedef struct _FILE_NOTIFY_INFORMATION { DWORD NextEntryOffset;

NextEntryOffset
Number of bytes that must be skipped to get to the next record. A value of zero indicates that this is the last record.


Иными словами, там не массив. Там линейный список, которым не ты управляешь. Заказать можно буфер любого размера, но

Upon successful synchronous completion, the lpBuffer parameter is a formatted buffer and the number of bytes written to the buffer is available in lpBytesReturned. If the number of bytes transferred is zero (0), the buffer was too small to provide detailed information on all the changes that occurred in the directory or subtree. In this case, you should compute the changes by enumerating the directory or subtree.

Вот это надо проверять.
With best regards
Pavel Dvorkin
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.