Recent

Author Topic: Problem with FindFirstChangeNotificationW in JwaWinBase  (Read 2965 times)

JimC

  • Newbie
  • Posts: 1
Problem with FindFirstChangeNotificationW in JwaWinBase
« on: August 01, 2018, 01:17:59 pm »
I'm trying to write a directory monitor using FindFirstChangeNotificationW and have struck a problem I can't resolve. All the documentation states the definition as

function FindFirstChangeNotificationW(lpPathName: LPCWSTR; bWatchSubtree: BOOL;  dwNotifyFilter: DWORD): HANDLE

however in JwaWinBase the definition is

function FindFirstChangeNotificationW(lpPathName: LPCWSTR; bWatchSubtree: Cardinal;  dwNotifyFilter: DWORD): HANDLE

It may be something simple but I don't know how to use the Cardinal vice boolean for bWatchSubTree, any assistance would be appreciated.   Using Lazarus  1.8.4, FPC 3.0.4 Windows 10 1803 Build 17134.165.
I know I'm re-inventing the wheel but I'm self taught and find learning via experimenting\doing suits me.
Thanks
JimC

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Problem with FindFirstChangeNotificationW in JwaWinBase
« Reply #1 on: August 01, 2018, 01:33:48 pm »
IIRC then on Windows BOOL = LongBool, which in essence is a DWORD?

Bart

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Problem with FindFirstChangeNotificationW in JwaWinBase
« Reply #2 on: August 01, 2018, 05:31:14 pm »
I don't know how to use the Cardinal vice boolean for bWatchSubTree
In C/C++ false is 0, which means true is any value that is *not* 0.

If you want bWatchSubTree to be false, pass 0.
If you want bWatchSubTree to be true, pass any number other than 0.

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: Problem with FindFirstChangeNotificationW in JwaWinBase
« Reply #3 on: August 02, 2018, 10:45:17 pm »
however in JwaWinBase the definition is
function FindFirstChangeNotificationW(lpPathName: LPCWSTR; bWatchSubtree: Cardinal;  dwNotifyFilter: DWORD): HANDLE
As far as I remember, in Windows 98, the bWatchSubtree parameter could only accept values 0 or 1, i.e. BOOL(0) or BOOL(1), i.e. it turns out that if you specify BOOL(-1), which is also True from the point of view of BOOL, then this led to an error. Therefore, was described a function where it is more difficult to make a mistake.

 

TinyPortal © 2005-2018