Solved

Network-mappings

Posted on 1998-04-22
1
252 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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