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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:57:12  来源:igfitidea点击:

How to create a windows registry watcher?

c#.netvb.netregistry

提问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 JP Alioto

回答by Alex

.Net framework does not contain embedded class to watch the registry. But you still can use wrapped WinAPI calls or WMI interface (see example)

.Net 框架不包含用于监视注册表的嵌入式类。但您仍然可以使用封装的 WinAPI 调用或 WMI 接口(参见示例

回答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调用来完成,并且您必须自己监视旧值和新值。是代码。