BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

File Change Notification

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Colin B Maharaj
Guest





PostPosted: Sat Aug 27, 2005 11:15 am    Post subject: File Change Notification Reply with quote



Hi folks, I was trying to find a procedure to monitor file updates in
Windows - instead I found one that monitor changes in a path where you
specify the change type. But I may be monitoring hundreds or thousands
of files and to do a file search in a path to see which file has changed
is going to be too time consuming.

Any better suggestions?
Thanks
Colin B Maharaj
Trinidad, WI
Back to top
Vladimir Stefanovic
Guest





PostPosted: Sat Aug 27, 2005 7:54 pm    Post subject: Re: File Change Notification Reply with quote



Quote:
[...] But I may be monitoring hundreds or thousands of files and to do a
file search in a path to see which
file has changed is going to be too time consuming.

Hmm... I don't know if such techique exists...

I have some projects that monitors specified folder
(and subfolders) for changes, and then I look what
file(s) is(are) changed.

I haven't found any time-delay problems.

I hold the previous files state (file size or file attributes) in
INI file and then compare it with changed once.

I suppose that the notification module you have is a
class, so can you make a couple of notification objects
(not only one) which will decrese the number of files to
monitor?

The problem I had with *all* change notification classes
I found so far was that the event is trigered *multiple*
times for one event ?!...

In practise, that means, when I have to do something (when
the change arrises), my processing code is executed multiple
times for the same set of data.




--
Best regards,
Vladimir Stefanovic




Back to top
JD
Guest





PostPosted: Sun Aug 28, 2005 6:21 pm    Post subject: Re: File Change Notification Reply with quote




"Vladimir Stefanovic" <antivari (AT) po (DOT) sbb.co.yu> wrote:
Quote:

[...] The problem I had with *all* change notification
classes I found so far was that the event is trigered
*multiple* times for one event ?!...

It's not actually. I had a similar problem and found another
application's process was the cause (AOL in this case). A
restart after unloading AOL fixed it.

~ JD


Back to top
Vladimir Stefanovic
Guest





PostPosted: Sun Aug 28, 2005 7:07 pm    Post subject: Re: File Change Notification Reply with quote

Quote:
It's not actually. I had a similar problem and found another
application's process was the cause (AOL in this case). A
restart after unloading AOL fixed it.

Hi,

I placed a sample of my code (that executes multiple
times for one change - new file or updated) at attachments
group.

Can you please check it on your machine?

(Maybe there is a bug in my code...)




--
Best regards,
Vladimir Stefanovic



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Aug 28, 2005 7:36 pm    Post subject: Re: File Change Notification Reply with quote


"Colin B Maharaj" <noreply (AT) myhost (DOT) com> wrote


Quote:
Hi folks, I was trying to find a procedure to monitor file updates
in Windows - instead I found one that monitor changes in a path
where you specify the change type. But I may be monitoring hundreds
or thousands of files and to do a file search in a path to see which file
has changed is going to be too time consuming.

What EXACTLY are you trying to monitor to begin with? Have you looked at
SHChangeNotifyRegister() yet?


http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/functions/shchangenotifyregister.asp


Gambit



Back to top
JD
Guest





PostPosted: Tue Aug 30, 2005 12:47 pm    Post subject: Re: File Change Notification Reply with quote


"Vladimir Stefanovic" <antivari (AT) po (DOT) sbb.co.yu> wrote:
Quote:

[...] Can you please check it on your machine?

I'll look at it as soon as I get a chance. In the mean time:

//-------------------------------------------------------------
void __fastcall TMonitorThread::Execute()
{
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: PostMessage(Application->MainForm->Handle, CUSTOM_MESSAGE, 0, 0 );
if( !FindNextChangeNotification(hFind) ) Terminate();
break;
case WAIT_TIMEOUT: break;
default : Terminate();
}
}
FindCloseChangeNotification(hFind);
}
}
//-------------------------------------------------------------

~ JD


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.