--
Best regards,
Harold Holmes
Lincoln Beach Software
http://www.lincolnbeach.com = Download Butler + SiteTrak + FlexSite
Check out the FindFirstChangeNotification family of API calls.
Nick Hodges
TeamB
Even better, here's a old message from my colleague Steve Schafer --
-------------------------------------
On Thu, 03 Jul 1997 14:09:09 -0400, Colby Makowsky <co...@cyberhq.com>
wrote:
>I would like to have an event occur
when a specific directory or
>registry key is updated. Similar to
the explorer, which 'Refreshes' the
>listview when a file is changed, i
would like to be able to do a similar
>thing with my app. Thank you!
[reply to your email message]
Here's an example of a thread object
that waits for file and directory
changes and pops up a message box
when one occurs:
type
TChangeThread = class(TThread)
protected
ChangeHandle: THandle;
FPathToWatch: String;
procedure Execute; override;
procedure NotifyChange;
public
constructor Create(const
PathToWatch: String);
end;
constructor
TChangeThread.Create(const PathToWatch: String);
begin
inherited Create(True);
FPathToWatch := PathToWatch;
FreeOnTerminate := True;
ChangeHandle :=
FindFirstChangeNotification(PChar(FPathToWatch),
True, FILE_NOTIFY_CHANGE_FILE_NAME
or
FILE_NOTIFY_CHANGE_DIR_NAME);
Resume;
end;
procedure TChangeThread.Execute;
var
WaitResult: DWORD;
begin
repeat
WaitResult :=
WaitForSingleObject(ChangeHandle, 500);
if WaitResult = WAIT_OBJECT_0 then
begin
Synchronize(NotifyChange);
FindNextChangeNotification(ChangeHandle);
end;
until Terminated;
FindCloseChangeNotification(ChangeHandle);
CloseHandle(ChangeHandle);
end;
procedure
TChangeThread.NotifyChange;
begin
ShowMessage('Change occurred in ' +
FPathToWatch);
end;
To begin notifications:
MyChgThread :=
TChangeThread.Create('D:\Scratch');
To end them:
MyChgThread.Terminate;
-Steve
-------------------------------------------------------------
Nick Hodges
TeamB
Nick Hodges (TeamB) wrote in message
<35590711....@forums.borland.com>...
>Harold,
>
>Even better, here's a old message from my colleague Steve Schafer --
Thanks Nick. Do you know if there is a API call to tell which particular
file was added/renamed/deleted?