We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Notification message

migue77
migue77 asked
on
Medium Priority
388 Views
Last Modified: 2010-04-04
Windows sent any notification message when he made any kind of reading/wrinting process in the diskett?
Comment
Watch Question

Commented:
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.

Commented:
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

Commented:
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;

hi, madshi...

mique77:

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

there we've discussed what Madshi proposed.

regs,
Black Death.
whoops - 12:41 AM and everybody's awake?
igor's looks good.

bye,

Black Death.

Commented:
My good friend,
My local time is 10:46 AM and be here several hours more
Regards, Igor
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

Commented:
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.
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.



Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Commented:
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.

Commented:
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.

Commented:
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

Commented:
Thanks, Tom...

Madshi.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.