Solved

Notification message

Posted on 1998-09-01
14
370 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
[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
  • 5
  • 4
  • 2
  • +2
14 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1338421
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
ID: 1338422
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
ID: 1338423
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:BlackDeath
ID: 1338424
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
ID: 1338425
whoops - 12:41 AM and everybody's awake?
igor's looks good.

bye,

Black Death.
0
 
LVL 5

Expert Comment

by:inter
ID: 1338426
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
ID: 1338427
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
 
LVL 20

Expert Comment

by:Madshi
ID: 1338428
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
ID: 1338429
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
ID: 1338430
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
ID: 1338431
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
ID: 1338432
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
ID: 1338433
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
ID: 1338434
Thanks, Tom...

Madshi.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tembedded WB animatid gifs not animated on some pcs 2 86
Wincontrol not (correctly) drawn 15 47
firemonkey Android Listview Sort items 7 70
shape, triangle, dbctrlgrid 3 31
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…

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