Solved

Notification message

Posted on 1998-09-01
14
362 Views
Last Modified: 2010-04-04
Windows sent any notification message when he made any kind of reading/wrinting process in the diskett?
0
Comment
Question by:migue77
  • 5
  • 4
  • 2
  • +2
14 Comments
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
ANY kind of reading/writing can only be watched with a little driver.
Though, look at APIs "FindFirstChangeNotification" and "ReadDirectoryChangesW" (the latter only for WinNT). Perhaps it's good enough for your needs.

Regards, Madshi.
0
 
LVL 4

Expert Comment

by:BoRiS
Comment Utility
migue77

check the SHChangeNotify API call

ShChangeNotify( SHCNE_CREATE or SHCNE_DELETE or SHCNE_MKDIR, SHCNF_PATH, 'some path', 'some path');

Check the API call for the proper usage of the 'some path' thingie can't remember the full CODE for this call...

Later
BoRiS
0
 
LVL 5

Expert Comment

by:inter
Comment Utility
Hi,
As far as I know it does not send a message. But you can do it with FindFirstChangeNotification clone of functions. Here is a class for tracking read and write in specified folder, create it, assign a notification function and it notifies you when read or write operations are performed in a specified folder(you can also check for additional information see the Create method-) When creating just give the directory (e.g. a: for your case)
Try and we will discuss it
Regards, Igor

// This one can poll a directory for changes
type
  TDirNotify = class(TThread)
  protected
    FDir : string;   //directory to watch
    FWObj: THandle;  //event handle given by OS
    FOnChange : TNotifyEvent;
    procedure SetDir(D : String);
    procedure Execute;override;
  public
    constructor Create(ADir : string);
    destructor Destroy;override;
    property Directory : string read FDir write SetDir;
    property OnChange : TNotifyEvent read FOnChange write FOnChange;
  end;

implementation


{$R *.DFM}

// ****************************************************************
// TDirNotify
// ****************************************************************

procedure TDirNotify.SetDir(D : String);
begin
  if D <> FDir then
  begin
    FDir := D;
    if FWObj <> 0 then
       FindCloseChangeNotification(FWObj);
    FWObj := FindFirstChangeNotification(PChar(FDir), false,
//                                             FILE_NOTIFY_CHANGE_FILE_NAME //or
//                                             FILE_NOTIFY_CHANGE_DIR_NAME or
//                                             FILE_NOTIFY_CHANGE_ATTRIBUTES or
//                                             FILE_NOTIFY_CHANGE_SIZE or
                                               FILE_NOTIFY_CHANGE_LAST_WRITE or
//                                             FILE_NOTIFY_CHANGE_SECURITY
                                               );
    if FWObj = INVALID_HANDLE_VALUE then
       raise Exception.Create('TDirNotify.SetDir : Can not hook a directory notification filter');
  end;
end;

procedure TDirNotify.Execute;
begin
  while not Terminated do
  begin
    if WaitForSingleObject(FWObj, 1000) = WAIT_OBJECT_0 then
    begin
      try //catch exceptions due to the user
        if Assigned(FOnChange) then FOnChange(Self);
      except
      end;
      FindNextChangeNotification(FWObj);
    end;
    Sleep(10);
  end;
end;

constructor TDirNotify.Create(ADir : string);
begin
  inherited Create(False);
  FWObj:= 0;
  Directory := ADir;
  FreeOnTerminate := true;
end;

destructor TDirNotify.Destroy;
begin
  if FWObj <> 0 then
     FindCloseChangeNotification(FWObj);
  inherited Destroy;
end;

0
 
LVL 1

Expert Comment

by:BlackDeath
Comment Utility
hi, madshi...

mique77:

take a look at
http://www.experts-exchange.com/topics/comp/lang/delphi/Q.10075628
(FindFirstFile)

there we've discussed what Madshi proposed.

regs,
Black Death.
0
 
LVL 1

Expert Comment

by:BlackDeath
Comment Utility
whoops - 12:41 AM and everybody's awake?
igor's looks good.

bye,

Black Death.
0
 
LVL 5

Expert Comment

by:inter
Comment Utility
My good friend,
My local time is 10:46 AM and be here several hours more
Regards, Igor
0
 
LVL 1

Expert Comment

by:BlackDeath
Comment Utility
hi, inter!

this was supposed to be a joke.
12:41 is the time the comments are stamped with.
btw: my local time is 10:11 now (should be 11:11 at your place, right?)

how are you?

Black Death

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hi BlackDeath... (wow, what a name)

BoRiS, SHChangeNotify is the other way round. YOU inform the system that something has changed. I never understood the sense of this API...

inter, looks nice.

Regards, Madshi.
0
 
LVL 1

Expert Comment

by:BlackDeath
Comment Utility
hi, madshi.

(what does that stand for?)

do you know the cigarette brand - Black Death?
ever seen my lung?
nearly no non-black things i like or have
und i didn't even ask for this label - it's just liek it is.

um es mit den Worten von Bill Cosby zu sagen:

(talking about the origin of "brain damage":)

this, ladies and gentlemen, was not a blessing -
it was a PUNISHMENT!!

no, really - anything wrong with that name?


anyweg,

hau rein -

Black Death.



0
 
LVL 4

Accepted Solution

by:
binkzz earned 30 total points
Comment Utility
You would have to make an vxd control, which is sofar still impossible in Delphi. Either get the new delphi 4, or use CBuilder or Visual Basic to create the controls, or download them if you can find them.

If you can't find them, I'll mail you a copy if you wish.

Hope this helps,

Binkzz
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Hi BlackDeath,

nothing wrong with your name, just wondered where it comes from...
Madshi stands for nothing. It's just a Veralberung (sounds like "Matsch") of Mathias that comes from my Zivildienst time. (Ohh, dieses Englisch/Deutsch-Kuddelmuddel ist echt grausam...)

And another Bill Cosby fan. I'm watching Pro7 every evening!  :-)

Und tschüß... Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
binkzz,

do you mean, you CAN make vxd's with Delphi 4? How??? In the moment we use vireo's VToolsD and Borland's C++ Builder. Can we link Delphi 4's C-like objects together with VToolsD? Has somebody converted the VToolsD headers to Delphi yet?

Thanx for your answer... Madshi.
0
 
LVL 4

Expert Comment

by:binkzz
Comment Utility
You can link C++ to Delphi and vica versa, not too sure about VToolsD, as I've never used that.

It's best to create the vxd controls with CBuilder and convert use them by delphi. You don't actually have to use delphi 4 for that, delphi 2 will actually accept it.

Hope this clears up a bit more,
Tom
0
 
LVL 20

Expert Comment

by:Madshi
Comment Utility
Thanks, Tom...

Madshi.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now