ReadDirectoryChangesW


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: ReadDirectoryChangesW

  1. #1
    nikita Guest

    ReadDirectoryChangesW


    I need to use the ReadDirectoryChanges API Function through VB6.
    All the structures needed seemed to be correctly declared and the compilator
    returns no error.
    But the FILE_NOTIFY_INFORMATION structure only receives the value 259 in
    the BytesReturned field and all the other fields are left blank.
    Can someone help me with a sample source code or even just an advice...

    Thanks a lot for interesting in my problem and all apologies for my poor
    english (I'm French... ;-)

  2. #2
    Monte Hansen Guest

    Re: ReadDirectoryChangesW

    FILE_NOTIFY_INFORMATION is a variable-lengthed self-relative structure. You
    need to pass a raw buffer of type byte array to ReadDirectoryChangesW. You
    then iterate the buffer using CopyMemory to copy the fixed portion of the
    FILE_NOTIFY_INFORMATION structure to a variable of type
    FILE_NOTIFY_INFORMATION. I would define the FileName parameter as a byte
    array of size 255. The NextEntryOffset field tells you where the next record
    is located relative to your current position.

    Also, don't trust ReadDirectoryChangesW on remote machines, it misses.

    HTH

    ++++++++++++++++++++
    Monte Hansen
    http://KillerVB.com
    ++++++++++++++++++++

    "nikita" <nikita22h90@aol.com> wrote in message
    news:3c3a3096$1@147.208.176.211...
    >
    > I need to use the ReadDirectoryChanges API Function through VB6.
    > All the structures needed seemed to be correctly declared and the

    compilator
    > returns no error.
    > But the FILE_NOTIFY_INFORMATION structure only receives the value 259 in
    > the BytesReturned field and all the other fields are left blank.
    > Can someone help me with a sample source code or even just an advice...
    >
    > Thanks a lot for interesting in my problem and all apologies for my poor
    > english (I'm French... ;-)




  3. #3
    Monte Hansen Guest

    Re: ReadDirectoryChangesW

    FILE_NOTIFY_INFORMATION is a variable-lengthed self-relative structure. You
    need to pass a raw buffer of type byte array to ReadDirectoryChangesW. You
    then iterate the buffer using CopyMemory to copy the fixed portion of the
    FILE_NOTIFY_INFORMATION structure to a variable of type
    FILE_NOTIFY_INFORMATION. I would define the FileName parameter as a byte
    array of size 255. The NextEntryOffset field tells you where the next record
    is located relative to your current position.

    Also, don't trust ReadDirectoryChangesW on remote machines, it misses.

    HTH

    ++++++++++++++++++++
    Monte Hansen
    http://KillerVB.com
    ++++++++++++++++++++

    "nikita" <nikita22h90@aol.com> wrote in message
    news:3c3a3096$1@147.208.176.211...
    >
    > I need to use the ReadDirectoryChanges API Function through VB6.
    > All the structures needed seemed to be correctly declared and the

    compilator
    > returns no error.
    > But the FILE_NOTIFY_INFORMATION structure only receives the value 259 in
    > the BytesReturned field and all the other fields are left blank.
    > Can someone help me with a sample source code or even just an advice...
    >
    > Thanks a lot for interesting in my problem and all apologies for my poor
    > english (I'm French... ;-)




  4. #4
    Dante Guest

    Re: ReadDirectoryChangesW


    Could someone tell me how to declare and use the ReadDirectoryChangesW
    with VB6?
    I read the MSDN docs but it didn't help me a lot.

    Any little help will be apreciated.
    Dante

  5. #5
    Dante Guest

    Re: ReadDirectoryChangesW


    Could someone tell me how to declare and use the ReadDirectoryChangesW
    with VB6?
    I read the MSDN docs but it didn't help me a lot.

    Any little help will be apreciated.
    Dante

  6. #6
    dnagel Guest

    Re: ReadDirectoryChangesW

    heres my best guess...

    'BOOL ReadDirectoryChangesW(
    ' HANDLE hDirectory, // handle to the directory to be watched
    ' LPVOID lpBuffer, // pointer to the buffer to receive the read
    ' // results
    ' DWORD nBufferLength, // length of lpBuffer
    ' BOOL bWatchSubtree, // flag for monitoring directory or
    ' // directory tree
    ' DWORD dwNotifyFilter, // filter conditions to watch for
    ' LPDWORD lpBytesReturned, // number of bytes returned
    ' LPOVERLAPPED lpOverlapped,
    ' // pointer to structure needed for
    ' // overlapped I/O
    ' LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
    ' // pointer to completion routine
    ');

    Public Type OVERLAPPED
    Internal As Long
    InternalHigh As Long
    offset As Long
    OffsetHigh As Long
    hEvent As Long
    End Type

    Private Declare Function ReadDirectoryChangesW Lib "Kernel32" _
    (ByVal hDirectory As Long, _
    lpBuffer As Any, _
    nBufferLength As Long, _
    bWatchSubtree As Long, _
    dwNotifyFilter As Long, _
    lpBytesReturned As Long, _
    lpOverlapped As OVERLAPPED, _
    ByVal lpCompletionRoutine As Long _
    ) As Long


    "Dante" <aldokappa@hotmail.com> wrote in message
    news:3c3c0fee$1@147.208.176.211...
    >
    > Could someone tell me how to declare and use the ReadDirectoryChangesW
    > with VB6?
    > I read the MSDN docs but it didn't help me a lot.
    >
    > Any little help will be apreciated.
    > Dante




  7. #7
    dnagel Guest

    Re: ReadDirectoryChangesW

    heres my best guess...

    'BOOL ReadDirectoryChangesW(
    ' HANDLE hDirectory, // handle to the directory to be watched
    ' LPVOID lpBuffer, // pointer to the buffer to receive the read
    ' // results
    ' DWORD nBufferLength, // length of lpBuffer
    ' BOOL bWatchSubtree, // flag for monitoring directory or
    ' // directory tree
    ' DWORD dwNotifyFilter, // filter conditions to watch for
    ' LPDWORD lpBytesReturned, // number of bytes returned
    ' LPOVERLAPPED lpOverlapped,
    ' // pointer to structure needed for
    ' // overlapped I/O
    ' LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
    ' // pointer to completion routine
    ');

    Public Type OVERLAPPED
    Internal As Long
    InternalHigh As Long
    offset As Long
    OffsetHigh As Long
    hEvent As Long
    End Type

    Private Declare Function ReadDirectoryChangesW Lib "Kernel32" _
    (ByVal hDirectory As Long, _
    lpBuffer As Any, _
    nBufferLength As Long, _
    bWatchSubtree As Long, _
    dwNotifyFilter As Long, _
    lpBytesReturned As Long, _
    lpOverlapped As OVERLAPPED, _
    ByVal lpCompletionRoutine As Long _
    ) As Long


    "Dante" <aldokappa@hotmail.com> wrote in message
    news:3c3c0fee$1@147.208.176.211...
    >
    > Could someone tell me how to declare and use the ReadDirectoryChangesW
    > with VB6?
    > I read the MSDN docs but it didn't help me a lot.
    >
    > Any little help will be apreciated.
    > Dante




  8. #8
    Monte Hansen Guest

    Re: ReadDirectoryChangesW


    Actually, as a matter of practice, I would declare it like so (:

    Declare Function ReadDirectoryChangesW(...
    Byval hDirectory as Long , _
    lpBuffer As Any, {watch this param!}
    Byval nBufferLength As Long, _
    Byval bWatchSubtree As Long, _
    Byval dwNotifyFilter As Long, _
    byref lpBytesReturned as Long, _
    Byval lpOverlapped As Long, _
    Byval lpCompletionRoutine As Long)As Long

    This is improv, so I hope I didn't get it wrong.

    +|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+
    Monte Hansen
    http://KillerVB.com
    +|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+

    "dnagel" <GrandNagel@hotmail.com> wrote:
    >heres my best guess...
    >
    >'BOOL ReadDirectoryChangesW(
    >' HANDLE hDirectory, // handle to the directory to be watched
    >' LPVOID lpBuffer, // pointer to the buffer to receive the read
    >' // results
    >' DWORD nBufferLength, // length of lpBuffer
    >' BOOL bWatchSubtree, // flag for monitoring directory or
    >' // directory tree
    >' DWORD dwNotifyFilter, // filter conditions to watch for
    >' LPDWORD lpBytesReturned, // number of bytes returned
    >' LPOVERLAPPED lpOverlapped,
    >' // pointer to structure needed for
    >' // overlapped I/O
    >' LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
    >' // pointer to completion routine
    >');
    >
    >Public Type OVERLAPPED
    > Internal As Long
    > InternalHigh As Long
    > offset As Long
    > OffsetHigh As Long
    > hEvent As Long
    >End Type
    >
    >Private Declare Function ReadDirectoryChangesW Lib "Kernel32" _
    > (ByVal hDirectory As Long, _
    > lpBuffer As Any, _
    > nBufferLength As Long, _
    > bWatchSubtree As Long, _
    > dwNotifyFilter As Long, _
    > lpBytesReturned As Long, _
    > lpOverlapped As OVERLAPPED, _
    > ByVal lpCompletionRoutine As Long _
    > ) As Long
    >
    >
    >"Dante" <aldokappa@hotmail.com> wrote in message
    >news:3c3c0fee$1@147.208.176.211...
    >>
    >> Could someone tell me how to declare and use the ReadDirectoryChangesW
    >> with VB6?
    >> I read the MSDN docs but it didn't help me a lot.
    >>
    >> Any little help will be apreciated.
    >> Dante

    >
    >



  9. #9
    Monte Hansen Guest

    Re: ReadDirectoryChangesW


    Actually, as a matter of practice, I would declare it like so (:

    Declare Function ReadDirectoryChangesW(...
    Byval hDirectory as Long , _
    lpBuffer As Any, {watch this param!}
    Byval nBufferLength As Long, _
    Byval bWatchSubtree As Long, _
    Byval dwNotifyFilter As Long, _
    byref lpBytesReturned as Long, _
    Byval lpOverlapped As Long, _
    Byval lpCompletionRoutine As Long)As Long

    This is improv, so I hope I didn't get it wrong.

    +|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+
    Monte Hansen
    http://KillerVB.com
    +|+|+|+|+|+|+|+|+|+|+|+|+|+|+|+

    "dnagel" <GrandNagel@hotmail.com> wrote:
    >heres my best guess...
    >
    >'BOOL ReadDirectoryChangesW(
    >' HANDLE hDirectory, // handle to the directory to be watched
    >' LPVOID lpBuffer, // pointer to the buffer to receive the read
    >' // results
    >' DWORD nBufferLength, // length of lpBuffer
    >' BOOL bWatchSubtree, // flag for monitoring directory or
    >' // directory tree
    >' DWORD dwNotifyFilter, // filter conditions to watch for
    >' LPDWORD lpBytesReturned, // number of bytes returned
    >' LPOVERLAPPED lpOverlapped,
    >' // pointer to structure needed for
    >' // overlapped I/O
    >' LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
    >' // pointer to completion routine
    >');
    >
    >Public Type OVERLAPPED
    > Internal As Long
    > InternalHigh As Long
    > offset As Long
    > OffsetHigh As Long
    > hEvent As Long
    >End Type
    >
    >Private Declare Function ReadDirectoryChangesW Lib "Kernel32" _
    > (ByVal hDirectory As Long, _
    > lpBuffer As Any, _
    > nBufferLength As Long, _
    > bWatchSubtree As Long, _
    > dwNotifyFilter As Long, _
    > lpBytesReturned As Long, _
    > lpOverlapped As OVERLAPPED, _
    > ByVal lpCompletionRoutine As Long _
    > ) As Long
    >
    >
    >"Dante" <aldokappa@hotmail.com> wrote in message
    >news:3c3c0fee$1@147.208.176.211...
    >>
    >> Could someone tell me how to declare and use the ReadDirectoryChangesW
    >> with VB6?
    >> I read the MSDN docs but it didn't help me a lot.
    >>
    >> Any little help will be apreciated.
    >> Dante

    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center