No announcement yet.

help with translation from MSDN for ReadDirectoryChangesW to monitor directories

  • Filter
  • Time
  • Show
Clear All
new posts

  • help with translation from MSDN for ReadDirectoryChangesW to monitor directories

    This seems like a very cool API and seemingly straight-forward enough - just call CreateFile to get a handle on the directory you want to monitor, and call this API - it's then supposed to get back to you when an event occurs in that directory (basically the same as FindFileNotification, but better because it tells you WHAT changed). Unfortunately it's only supported on NT and Win2K, not Win9x.

    Here's the reference for ReadDirectoryChangesW -

    There's also a very small and simple visual c++ demo at
    Even I was able to compile it but that's no good because I can't read C++ <grin> - it worked well though

    Is there anybody kind enough that could help me translate these so as to call them from PB? It may even be possible to monitor C:\ and all subdirectories in the one API call, but as Im not good enough with PB yet as to be able to translate MSDN definitions to it, I'm a bit stuck

    Here's the MSDN definitions:
    BOOL ReadDirectoryChangesW(
      HANDLE hDirectory,                                  // handle to directory
      LPVOID lpBuffer,                                    // read results buffer
      DWORD nBufferLength,                                // length of buffer
      BOOL bWatchSubtree,                                 // monitoring option
      DWORD dwNotifyFilter,                               // filter conditions
      LPDWORD lpBytesReturned,                            // bytes returned
      LPOVERLAPPED lpOverlapped,                          // overlapped buffer
      LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine // completion routine
    typedef struct _FILE_NOTIFY_INFORMATION {
      DWORD NextEntryOffset;
      DWORD Action;
      DWORD FileNameLength;
      WCHAR FileName[1];
    Here's my PB translation:
      NextEntryOffset AS DWORD
      Action AS DWORD
      FileNameLength AS DWORD
      FileName AS STRING * 1
    DECLARE FUNCTION ReadDirectoryChangesW LIB "KERNEL32.DLL" ALIAS "ReadDirectoryChangesW" ( _
      hDirectory AS LONG, _
      nBufferLength AS DWORD, _
      bWatchSubtree AS INTEGER, _
      dwNotifyFilter AS DWORD, _
      lpBytesReturned AS DWORD, _
      xtmp1 AS DWORD, _
      xtmp2 AS DWORD) AS LONG
    It compiles fine, but I'm not sure if the translation is correct, and Ive got no idea how to call such a beast!


    [This message has been edited by Wayne Diamond (edited April 09, 2001).]