Brad Hall wrote:
> Does anyone have any eg's of the "ReadChangeNotification" Win API? I
> want to implement it into a prog I have, but the Web hasn't been as
> helpful as I thought on this one...

Perhaps that's because there's no such thing as ReadChangeNotification.

Try you search using the correct name, FindFirstChangeNotification, and 
see whether that helps.

Also try the classes in the VirtualShellNotifier unit, part of Jim 
Kueneman's free Virtual Shell Tools package.

http://www.mustangpeak.net/

> And does the API run in the background of my prog so that my prog can
> continue to execute as normal, or am I going to have to thread the API
> call (I read something about a Wait state)?

FindFirstChangeNotification returns a handle. To be notified that a 
change has occured, you need to wait on that handle. WaitForSingleObject 
is the easiest way to wait, but it's also a blocking call. The thread 
that calls that function won't do anything else until the change 
notification is satisfied, so you'll need to use a separate thread for that.

When your program terminates, you'll want to tell the waiting thread 
that it should stop waiting. To do that, you'll need to have a way of 
waking it up without changing the file system. Instead of 
WaitForSingleObject, use WaitForMultipleObjects. In addition to the 
change-notification handle, you can also use an event handle (see 
CreateEvent). When the main thread want the notification thread to 
terminate, it can signal the event, which will cause 
WaitForMultipleObjects to stop waiting.

There is a way to do all this without a separate thread, but it gets 
much more complicated, and Delphi wasn't really designed to work this 
way. You can wait on handles while still handling messages y calling 
MsgWaitForMultipleObjects. It stops blocking when a message arrives, at 
which point you can call Application.ProcessMessages and then resume 
waiting. If you have a dialog box or modal form open, then there is a 
separate message loop active, and that loop doesn't know about the 
handles you're waiting on, so certain events might go unnotices for a 
while. I think a separate thread is much easier to work with.

-- 
Rob


------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hk1mijc/M=362329.6886308.7839368.1510227/D=groups/S=1705115362:TM/Y=YAHOO/EXP=1122932880/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~-> 

-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to