Solved

Network-mappings

Posted on 1998-04-22
1
249 Views
Last Modified: 2010-04-06
Under W95 and NT4 i want to intercept changes in network-mappings. (lpt-mappings and drive-letter changes, you know, the NET USE - stuff).
How can i make my own-code launch when an other program changes such a mapping.
With a timer,  i currently check the mappings every few seconds, but this is time-consuming.

Any ideas ?
0
Comment
Question by:mvz121697
1 Comment
 
LVL 5

Accepted Solution

by:
inter earned 50 total points
ID: 1336070
Hi,
The network connections are stored in the registry key(and sub keys in)
HKEY_CURRENT_USER\Network
for example if there is a mapped Z drive its info is in
HKEY_CURRENT_USER\Network\Z
You can automatically notified a change in the Network key and its all subkeys with
the following API:

LONG RegNotifyChangeKeyValue(
    HKEY hKey,      // handle of key to watch
    BOOL bWatchSubtree,      // flag for subkey notification
    DWORD dwNotifyFilter,      // changes to be reported
    HANDLE hEvent,      // handle of signaled event
    BOOL fAsynchronous       // flag for asynchronous reporting  
   );      
 
So the procedure is:
1 - Open the Network key and get its handle
2 - Create a Event object
3 - With keyhandle, bWatchSubtree = true and event handle call the above Api setting fAsynchronous = true.
4 - Create a thread just for watching the event, it should use WaitSingleObject to check if a mapping is changed
5 - If smth changed your thread is notified by Windows so do what you want,

Regards,(If you have trouble in programming this, I (or somebody else with this method) try to program, but I have no time by now)
Igor
0

Featured Post

What Is Threat Intelligence?

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

Join & Write a Comment

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

706 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

15 Experts available now in Live!

Get 1:1 Help Now