Wrote a function (I don’t think it’s right) that tracks changes in a folder:
bool if_changes(wstring path) { path += L"\\"; LPWSTR lpath = const_cast<LPWSTR>(path.c_str()); HANDLE hDir = CreateFileW(lpath, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL); BYTE outBuffer[5120]; VOID *pBuf = (BYTE*)&outBuffer; DWORD InfoNotify; BOOL ResultReadChange; DWORD outSize = sizeof(outBuffer); HANDLE ReadChange; ReadChange = FindFirstChangeNotificationW(lpath, TRUE, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_SIZE); ResultReadChange = FindNextChangeNotification(ReadChange); FindCloseChangeNotification(ReadChange); return ResultReadChange; } In the main program loop, by the condition of changes in the folder, I perform fairly process-intensive actions. But for some reason, the function constantly sees changes in the folder, even when they are not really there. I used ReadDirectoryChangesW() , but it does not continue program execution, but waits for any changes in the folder when I need to check the changes and run further. Actually the question: what did I do wrong and what should I do to work as in my description?