Article View: borland.public.cppbuilder.nativeapi
Article #17213Is FindFirstChangeNotification half blind?
From: Peter Elbertse
Date: Thu, 03 Apr 2003 10:45
Date: Thu, 03 Apr 2003 10:45
60 lines
3346 bytes
3346 bytes
Hi everyone,
I'm working on a Client-Server project in which I let the server download updates which will be
spread over the clients.
To monitor changes to the downloaded updates (when some silly person manually deletes one of the
update files), I created a thread to monitor the directory in which the files need to be. For this I
use the FindFirstChangeNotification API.
It works pretty good. It detects the removal of the Directory and it detects the removal of any File
within the Directory.
BUT... when I delete the Directory when it contains files, FindFirstChangeNotification doesn't
detect it.
I was pretty stumped when I found this out and have been searching through deja.com for any answers,
but couldn't find any.
Does someone has any idea what to do, or what i'm doing wrong?
Thanks in advance,
Peter Elbertse
The Source:
//===========================================================
//Check files on the creation of this thread:
CheckUpdateFiles();
//Loop while the Thread is not terminated:
do
{
//Now try to create all directories if needed:
if (!DirectoryExists( ExtractFilePath( ExpandFileName(sInternalDirectory + "\\" +
"NULL") ) ) )
ForceDirectories( ExtractFilePath( ExpandFileName(sInternalDirectory + "\\"
+ "NULL") ) );
//Set var:
ListenHandle = FindFirstChangeNotification(sInternalDirectory.c_str(), TRUE,
FILE_NOTIFY_CHANGE_FILE_NAME)
DWORD dResult = WAIT_TIMEOUT;
FindNextChangeNotification(ListenHandle);
while (dResult == WAIT_TIMEOUT && !Terminated)
{
//Listen for 10 seconds.
dResult = WaitForSingleObject(ListenHandle, 10000);
}
//We have a DWORD value. Now use it:
if (dResult == WAIT_OBJECT_0)
//Check files now:
CheckUpdateFiles();
//Close notification:
FindCloseChangeNotification(ListenHandle);
}
while (!Terminated);
//===========================================================
Technical Details
Message-ID:
<3e8c0fa7$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!out.nntp.be!propagator2-sterling!news-in-sterling.newsfeed.com!newshosting.com!news-xfer1.atl.newshosting.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,e4bd711f5b42d795,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-03 02:56:07 PST From: "Peter Elbertse" <zoetjuh@wanadoo.nl> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Is FindFirstChangeNotification half blind? Date: Thu, 3 Apr 2003 12:45:53 +0200 Lines: 62 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 212.238.183.121 Message-ID: <3e8c0fa7$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1049366439 212.238.183.121 (3 Apr 2003 02:40:39 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!news.maxwell.syr.edu!out.nntp.be!propagator2-sterling!news-in-sterling.newsfeed.com!newshosting.com!news-xfer1.atl.newshosting.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail