Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FindFirstChangeNotification

173 views
Skip to first unread message

Mohan

unread,
Aug 29, 2000, 3:00:00 AM8/29/00
to
Hi,

In my application I want to reload a document if it has been modified
outside the source editor. So I'm using FindFirstChangeNotification to
detect for a change in the directory. I have a WaitForMultipleObjects on the
handle returned.

My problem occurs if the user is running the application on Windows 98. If
the document is modified by a user on another Computer,
WaitForMultipleObjects doesn't register the change and thus the document is
not updated. Any ideas why this might be happening and what can I do ?

Everything works fine on Win NT !!

Thanks & Regards,
Mohan

Mohamed Badr

unread,
Aug 29, 2000, 3:00:00 AM8/29/00
to
Hi
I don't use WaitForMultipleObjects but FindFirstChangeNotification can
monitor a file not only for directory.also it detect if the file is changed
anywhere even from other machine.
best regards
M. Badr
"Mohan" <mr...@cyberworldcorp.com> wrote in message
news:#9WZ#2dEAH...@cppssbbsa02.microsoft.com...

Les Matheson

unread,
Aug 29, 2000, 11:55:52 PM8/29/00
to
I've had problems in more than one case with
missing notifications from FindFirstChangeNotification. Basically,
I stopped trusting it several years ago, and now I poll for file
system changes. Crude but reliable.

David Crow [MCSD]

unread,
Aug 30, 2000, 3:00:00 AM8/30/00
to
What does your code look like?

Mohan

unread,
Aug 30, 2000, 3:00:00 AM8/30/00
to

Hi,

Its something like this -

HANDLE aHandles[2];
aHandles[0] = hChange;
aHandles[1] = hEvent;

while (bContinue)
{
if((::WaitForMultipleObjects(2, aHandles, FALSE, INFINITE) -
WAIT_OBJECT_0) == 0)
{
if(pWnd)
{
//Check if the document that we are monitoring has changed
//if it has then display a message and reload it

CFile::GetStatus(LPCTSTR(sFileName),rStatus);

if(rStatus.m_mtime.GetTime() > tCurrentTime.GetTime())
{

tCurrentTime = rStatus.m_mtime;
if((CMyDocument*)pDocument)->m_iDocumentStatus == READONLY)
{
//We need to send this message only for Read Only Documents
pWnd->PostMessage(uRefreshDocument,(WPARAM)pDocument);
}
}

}
if(::FindNextChangeNotification (hChange))
{
bContinue = TRUE;
}
else
{
bContinue = FALSE;
}

}
else
{
// Kill this thread (m_event became signaled).
bContinue = FALSE;
}
}

// Close the file change notification handle and return.
::FindCloseChangeNotification (hChange);
return 0;

0 new messages