C# 如何创建 Windows 注册表观察程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/846366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a windows registry watcher?
提问by Amr Elgarhy
How to create a windows registry watcher application using .Net,
如何使用 .Net 创建 Windows 注册表观察器应用程序,
I want this application to watch all the registry hooks and fire an event when a value change, this event will tell the old and new valuefor that value.
我希望此应用程序监视所有注册表挂钩并在值更改时触发事件,此事件将告诉该值的旧值和新值。
Thats possible? how? need just the idea or where to start
那可能吗?如何?只需要想法或从哪里开始
采纳答案by cletus
回答by JP Alioto
This looks like a good place to start. There is a WMIclass for the registry.
这看起来是个不错的起点。注册表有一个WMI类。
回答by Alex
回答by user
The subscription can be done either via WMIor directly via blocking RegNotifyChangeKeyValuecall in a separate thread, and you'll have tomonitor the old and the new values for yourself. Hereis the code.
订阅可以通过 WMI或直接通过在单独的线程中阻止RegNotifyChangeKeyValue调用来完成,并且您必须自己监视旧值和新值。这是代码。