• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

Notification message

Windows sent any notification message when he made any kind of reading/wrinting process in the diskett?
0
migue77
Asked:
migue77
  • 5
  • 4
  • 2
  • +2
1 Solution
 
MadshiCommented:
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
 
BoRiSCommented:
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
 
interCommented:
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

 
BlackDeathCommented:
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
 
BlackDeathCommented:
whoops - 12:41 AM and everybody's awake?
igor's looks good.

bye,

Black Death.
0
 
interCommented:
My good friend,
My local time is 10:46 AM and be here several hours more
Regards, Igor
0
 
BlackDeathCommented:
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
 
MadshiCommented:
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
 
BlackDeathCommented:
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
 
binkzzCommented:
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
 
MadshiCommented:
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
 
MadshiCommented:
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
 
binkzzCommented:
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
 
MadshiCommented:
Thanks, Tom...

Madshi.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 5
  • 4
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now