Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,


I want my application to be notified when the hostname of the system on which it is running changes. Is there some way to do it in C# ?

I am looking for something similar to NetworkChange.NetworkAddressChanged which will raise an event whenever the IP address of the system changes and hence applications can be notified.

Thanks for the help.
Posted
Comments
Bernhard Hiller 26-Jan-12 6:33am    
Isn't it necessary to re-start the computer for the hostname change to take effect?

1 solution

One solution can be this :

Hostname is stored in registry at address :
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName

under the key name of ComputerName

Get notified of its changes by this way:
http://stackoverflow.com/questions/4233746/c-receive-notification-when-registrykey-value-was-changed[^]

There are also other solutions to watch for registry changes which can be found by Google.

Hope it helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900