[Lazarus] Shell notifications

Henry Vermaak henry.vermaak at gmail.com
Thu Aug 22 14:06:27 CEST 2013


On Thu, Aug 22, 2013 at 01:49:28PM +0200, Sven Barth wrote:
> Am 22.08.2013 13:33, schrieb Antonio Fortuny:
> >See the code in attachment
> >
> >I changed the code a little bit adding the OVERLAP parameter and
> >events to use the async method.
> >Now the same function returns error code 6
> Error code 6 is ERROR_INVALID_HANDLE (would be nice if you'd mention
> the error message as well next time when you're already using
> SysErrorMessage). FindFirstChangeNotification returns a notification
> handle, but ReadDirectoryChanges requires a directory handle (with
> FILE_LIST_DIRECTORY priviledge), so you need to open the directory
> yourself.

To add to this, the remarks section on msdn says this:

"To obtain a handle to a directory, use the CreateFile function with the
FILE_FLAG_BACKUP_SEMANTICS flag."

In addition to this you're also passing an OVERLAPPED record to
ReadDirectoryChangesW(), so you'll have to use FILE_FLAG_OVERLAPPED when
you open the directory, too.

Henry




More information about the Lazarus mailing list