Article View: borland.public.cppbuilder.nativeapi
Article #3680Re: ReadDirectoryChangesW
From: JD
Date: Thu, 18 May 2006 10:57
Date: Thu, 18 May 2006 10:57
33 lines
2152 bytes
2152 bytes
Rod <notat022005@end.of.msg> wrote:
>
> [...] How do I implement the function ReadDirectoryChangesW
> asynchronously?
Have you looked at the win32 API FindFirstChangeNotification?
//-------------------------------------------------------------
void __fastcall TMonitorThread::Execute()
{
int Counter = 0;
HANDLE hFind = FindFirstChangeNotification(FPath.c_str(), false, FILE_NOTIFY_CHANGE_LAST_WRITE);
if( hFind != INVALID_HANDLE_VALUE )
{
while( !Terminated )
{
switch( WaitForSingleObject(hFind, 500) )
{
case WAIT_OBJECT_0: ++Counter;
::SendMessage(Application->MainForm->Handle, APP_FILECHANGE_NOTIFICATION, Counter, 0 );
if( !FindNextChangeNotification(hFind) ) Terminate();
break;
case WAIT_TIMEOUT: break;
default : Terminate();
}
}
FindCloseChangeNotification(hFind);
}
}
//-------------------------------------------------------------
~ JD
Technical Details
Message-ID:
<446c532a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<btnj629qq4hcqg2rm80fr6mdo9d1uv7ida@4ax.com> <4469ea36@newsgroups.borland.com> <gubm62dc961n3brhgmkmm6ptpc3o4oob5f@4ax.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f9b15488efc2a992 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: ReadDirectoryChangesW Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 64.12.116.201 X-Forwarded-For: 172.161.219.76 References: <btnj629qq4hcqg2rm80fr6mdo9d1uv7ida@4ax.com> <4469ea36@newsgroups.borland.com> <gubm62dc961n3brhgmkmm6ptpc3o4oob5f@4ax.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <446c532a$1@newsgroups.borland.com> Date: 18 May 2006 03:57:46 -0700 X-Trace: newsgroups.borland.com 1147949866 207.105.83.66 (18 May 2006 03:57:46 -0700) Lines: 34 Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail