В коде функция
ReadDirectoryChangesW() возвращает ноль:
#define pathDir "Z:\\"
DWORD WINAPI ThreadFunc(LPVOID lpParam)
{
HANDLE hDir = CreateFile(_T(pathDir), // pointer to the file name
FILE_LIST_DIRECTORY, // access (read/write) mode
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, // share mode
NULL, // security descriptor
OPEN_EXISTING, // how to create
FILE_FLAG_BACKUP_SEMANTICS, // file attributes (FILE_FLAG_OVERLAPPED)
NULL); // file with attributes to copy
const DWORD dwNotificationFlags = FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_FILE_NAME;
FILE_NOTIFY_INFORMATION Buffer[1024];
DWORD BytesReturned;
VOID *pBuf = (BYTE*)&Buffer;
while (ReadDirectoryChangesW(hDir, // handle to directory
&Buffer, // read results buffer
sizeof(Buffer), // length of buffer
TRUE, // monitoring option
dwNotificationFlags,
&BytesReturned, // bytes returned
NULL, // overlapped buffer
NULL)) // completion routine
{
FILE_NOTIFY_INFORMATION* pInfo = (FILE_NOTIFY_INFORMATION*) pBuf;
SelectAction(pInfo);
}
dwError = GetLastError();
CloseHandle(hDir);
return 0;
}
GetLastError() выдает, что код ошибки
ERROR_INVALID_FUNCTION Incorrect function.На
MSDN ReadDirectoryChangesW Function есть такое:
Return Value
If the function fails, the return value is zero. To get extended error information, call GetLastError.
If the network redirector or the target file system does not support this operation, the function fails with ERROR_INVALID_FUNCTION.
В посте
Нужен алгоритм пишут:
"Я проверял только на сетевом диске с NTFS. Там ReadDirectoryChangesW работал."
Как заставить работать
ReadDirectoryChangesW()?VS 2008