[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Detect a file change

Posted on 1997-09-05
7
Medium Priority
?
771 Views
Last Modified: 2012-08-13
How to detect a file has been changed using something like a shell extension or a hook...

(I don't want a TTimer with constantly checking if a file's date is any different)
0
Comment
Question by:kolarb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1343963
For what do you want to know the change of the file?
 Progressbar for copy of file?

Why has it be checked the whole time?
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1343964
You can do  this with setting Notification but only in WindowsNT. In WIndows95 this is impossible and you must use timer.

For WinNT i can write simple code.
0
 
LVL 2

Author Comment

by:kolarb
ID: 1343965
ZifNab: When a user changes a file a program should be run. It is known which files should be looked at.

mirek: ?? check examples/demos/shellext examples in Delphi3. I thought something like that should be possible. Anyway show me your NT code and I'll reconsider your answer.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Expert Comment

by:arh
ID: 1343966
As far as i know, there is no shell extension of this kind. But there is a pair of API functions - FindFirstChangeNotificaion/FindNextChangeNotification, available in both win95 and NT, which will notify you when any file in a particular directory has been changed. You should determine which particular file in that directory was changed by examining its date/time or something like that.
And to receive such notification your program should be running
constantly in background.
Sorry, i can't give you an example now.
0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 200 total points
ID: 1343967
Thanx to arh !!!!

As "arh" write i try test if notification works on Win95.
I found so yes but with some limitations. I don't have enought time to test what working and what not working but this example working.

var stop : boolean;

procedure TForm1.Button1Click(Sender: TObject);
var
  dwWaitStatus   : DWORD;
  dwChangeHandle : THandle;
begin
  Stop := False;
  dwChangeHandle := FindFirstChangeNotification(
    'C:\',                        //  directory to watch
    FALSE,                        // do not watch the subtree
                                  // in Win95 You can't set this to true !!!!
    FILE_NOTIFY_CHANGE_DIR_NAME); // watch filename changes

  if dwChangeHandle=INVALID_HANDLE_VALUE then
    begin
      ShowMessage('I can''t set notification' );
      ExitProcess(GetLastError)
    end;
  while (stop=false) do
  begin
    dwWaitStatus := WaitForSingleObject(dwChangeHandle, 100);
    if dwWaitStatus=WAIT_OBJECT_0 then
      begin
        Memo1.Lines.Add( 'File Created, Renamed or Deleted in C:\' );
      //here you can compare previous list of files with current list of files
      //and find what was changed
        if FindNextChangeNotification(dwChangeHandle)=FALSE then
        begin
          ShowMessage('I can''t restart notification' );
          ExitProcess(GetLastError);
        end;
      end;
    Application.ProcessMessages;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  Stop := True;
end;



0
 
LVL 2

Author Comment

by:kolarb
ID: 1343968
Excellent!
Will try it now and grade the answer.
0
 
LVL 2

Author Comment

by:kolarb
ID: 1343969
Thank you guys&gals.
Searched the MSDN and found this example with other settings.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question