title: Monitoring directory using ReadDirectoryChangesW API
body: <p>I am trying to monitor a directory <code>e:\test</code> using <a href="http://msdn.microsoft.com/en-us/library/aa365465%28VS.85%29.aspx" rel="nofollow">ReadDirectoryChangesW</a> API.</p>
  
  <p><strong>My Code :</strong> </p>
  
  <pre><code>#define UNICODE
  #define WIN32_WINNT 0x0500
  #include "stdafx.h"
  #include &lt;stdio.h&gt;
  #include &lt;windows.h&gt;
  
  
  HANDLE hDir;
  
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      FILE_NOTIFY_INFORMATION fniDir;
      DWORD i = 0;
  
      hDir = CreateFile(_T("e:\\test"), GENERIC_READ , FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
  
      ReadDirectoryChangesW(hDir, &amp;fniDir, sizeof(fniDir), TRUE, FILE_NOTIFY_CHANGE_FILE_NAME, &amp;i, NULL, NULL);
      while(TRUE)
      {
  
  
      if(i&gt;0)
          wprintf(L"%s", fniDir.FileName);
      }
  
      CloseHandle(hDir);
  
      return 0;
  }
  </code></pre>
  
  <p>I don't know what's wrong with my code as I haven't understood ReadDirectoryChangesW documentation completely, specially the <code>LPOVERLAPPED</code>  parameters.</p>
  
  <p>When I run the code I don't get any output, except for a blank console window. Can someone point me in a right direction?</p>
  
  <p>Thanks.</p>