views:

173

answers:

1

I want to monitor upon a specified directory and if there's any file or subdirectory changes, I can be notified. I realize the function with the following simple code segment:

UINT myThreadFunc(LPVOID pParam)
{
  int changeCount = 0;

  while(true)
  {
 HANDLE changeHandle = FindFirstChangeNotification(L"C:\\", TRUE, FILE_NOTIFY_CHANGE_FILE_NAME);
 WaitForSingleObject(changeHandle, INFINITE);
 cout<<"A modifaction has occured"<<endl;
 changeCount++;

 if (changeCount >= 10)
  break;
 if ( FindNextChangeNotification( changeHandle ) == FALSE )
  break;
  }
  bIsExit = TRUE;
  return 0;
}

Now I want to retrieve the file information such as Action type or FileName. How can I get this information? I don't want to use ReadDirectoryChangesW function.

Thank you very much!

+2  A: 

MSDN states :

This function does not indicate the change that satisfied the wait condition. To retrieve information about the specific change as part of the notification, use the ReadDirectoryChangesW function.(check link text)

da_m_n