当系统的主机名更改时获得通知 [英] Get notification when the system's hostname changes

查看:97
本文介绍了当系统的主机名更改时获得通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我希望在运行它的系统的主机名发生变化时得到通知.有什么办法可以在C#中做到这一点?

我正在寻找类似于NetworkChange.NetworkAddressChanged的东西,每当系统的IP地址发生更改并因此可以通知应用程序时,都会引发一个事件.

感谢您的帮助.

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.

推荐答案

一个解决方案可以是:

主机名存储在注册表中的地址:
One solution can be this :

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


ComputerName
的键名下
通过以下方式获得有关其更改的通知:
http://stackoverflow.com/questions/4233746/c-receive-通知-when-registrykey-value-已更改 [ ^ ]

Google还提供了其他解决方案来监视注册表更改.

希望对您有所帮助.


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.


这篇关于当系统的主机名更改时获得通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆