Solved

Network-mappings

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 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