Solved

FindFirstChangeNotification

Posted on 1998-08-06
16
794 Views
Last Modified: 2008-02-01
i am using FindFirstChangeNotification / FindNextChangeNotification in a thread and it works fine.
What reports is only that something has changed in the defined directory or below.

I need to know in which subdir. the change was.
How can i use the handle (h) to find details?

path := stralloc(64);
path := 'c:\temp\';
h := FindFirstChangeNotification(path, BOOL(1), FILE_NOTIFY_CHANGE_FILE_NAME OR FILE_NOTIFY_CHANGE_DIR_NAME);
0
Comment
Question by:kyr
  • 6
  • 5
  • 2
  • +3
16 Comments
 

Expert Comment

by:kashif063098
ID: 1361636
hi
you can use Win32 api GetFileInformationByHandle() to get additional info of directory or file


0
 

Expert Comment

by:kashif063098
ID: 1361637
if you example,please let me know

0
 

Author Comment

by:kyr
ID: 1361638
are you sure?
Does GetFileInformationByHandle work with the handle that
FindFirstChangeNotification returns?

I couldn't make it work...
Actually this handle is a handle to a find change notification object.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 20

Expert Comment

by:Madshi
ID: 1361639
As far as I know, FindFirstChangeNotification is just stupid. You can't get further infos from your handle.  :-(
But I'm not so absolutely sure...
We solved this problem with a vxd driver. You can find a vxd sample "FileMonitor" on "www.sysinternals.com". It's just what you need. But I don't know if you really want to work with drivers. If you want, you'll need the example (see above) and Microsoft or Borland C compiler and vireo's vToolsD.
Sorry!
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1361640
Use ReadDirectoryChangesW instead

This gives you access to a structure called FILE_NOTIFY_INFORMATION which contains the name of the file and the operation performed.


0
 
LVL 20

Expert Comment

by:Madshi
ID: 1361641
Works only with WinNT, I suppose...  :-(
0
 

Expert Comment

by:JimmyWhite
ID: 1361642
hi,

Look at Torry's Delphi Pages in the section vcl, files and drives or something like that and you will find 3 or 4 components with source which will do exactly what you want.
The best are : dirchange and dirmon.
0
 

Author Comment

by:kyr
ID: 1361643
Answers2000:
It is only for NT sorry... i cannot accept it. I cannot ever give it a try

JimmyWhite:
This is not what i am looking for.
The first one only tells you a change has occured, while the other one only monitors the current level of the giver directory, not its subs.

QUESTION TURNS TO:
what i found best is to try to connect to filevxd.vxf from filemon at www.sysinternals.com, and do the rest.
But i cannot convert the c code to obj.pascal (source code from site above).
I would appreciate any help to do this
(increased points to 150-tell me for more.)

0
 

Author Comment

by:kyr
ID: 1361644
Adjusted points to 150
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1361645
I'm not sure. Do you want to
(1) build the driver itself in Delphi or
(2) use vireo's driver and communicate with it in Delphi?
As far as I know (1) does not work at all. (2) should be possible, but where is your problem? Don't you understand C(++)? If so, I cannot help you, because I don't have the time to do the whole work for you. But if there are only some specific problems, tell me details...

Regards, Madshi.
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1361646
0
 

Author Comment

by:kyr
ID: 1361647
ronit: they say nothing of great interest.
it is not that you/they cannot help.

i understand i am using the wrong approach.

the sysinternals vxd driver is abslutely the best solution.

Dear Madshi,
  -can i freely use the driver with a project currently developing?
  -i finally managed to connect to it from delphi and it works perfectly.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1361648
kyr,

that's a good question. I don't know that either, because we built our own driver and only looked at the sysinternals sources. Please write to "cogswell@winternals.com". He will answer your question.

Regards, Madshi.
0
 

Author Comment

by:kyr
ID: 1361649
i am giving you the points Madshi!
please propose it as answer.
question is closed.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 150 total points
ID: 1361650
Thanks, kyr...   :-)
0
 

Author Comment

by:kyr
ID: 1361651
thanks too...

cu
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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