.net 2.0 - Registry Watcher C# -


I am a newbie for WMI and I need to implement in the C # service.

I need an event handler that gets triggered every time, a set of registry values ​​changes. I want behavior similar to class event, but for registry values.

If there is any other technique that I can use to accomplish the same work, then I also appreciate it. My minimum expectation is that this would be the better solution I now have: voting in every 20 seconds and comparing the registry value with the end result.

Please provide example code in your answer. If I can just get an example of seeing a registry value, then it will be fine.

I need a solution in Net 2.0

Thank you.

WMI can sometimes be interesting to work with ... I think I I understand the question, so take a look at the code snippet below and let me know that this is what you are looking for.

  // --------------------------- ----------- --------------------------------------- ----------- ----------------------------- // & lt; Copyright file = "program cs" company = "" & gt; // // & lt; / Copyright & gt; // & lt; Summary & gt; // WMIChangeEventTester defines the type // & lt; / Summary & gt; // ------------------------------------------------ -------------------------------------------------- ------------------- Namespace WmiExample {Using System; Using System.Management; /// & lt; Summary & gt; /// & lt; / Summary & gt; Public Sector WMIChangeEventTester {/// & lt; Summary & gt; Starts a new instance of ///; & Lt; See cref = "WmiChangeEventTester" /> class. /// & lt; / Summary & gt; Public WMIChangeEventTester () {try {// your query goes down; "Keypath" is the key in the registry that you want to monitor // changes. Make sure that you avoid \ character \ WqlEventQuery query = new WqlEventQuery ("Choose from RegistryValueChangeEvent *" + "hive = 'HKEY_LOCAL_MACHINE' '+ @" And mainpath = 'software \\ Microsoft \\ NETFramework.' And ValueName = 'InstallRoot' '); Management Entrepreneur Viewer = New Management Event Water (query); console.lightline ("Waiting for an event ... "); // Set that representative, Watcher.EventArrived + = New EventEarthedEventHandler (HandleInvent); // Start listening for events; watcher.Start (); // Do something while waiting for the event in your application, // it's always like The business will continue. Stop listening to System.Threading.Thread.Sleep (100000000); // events; watcher. Stop ();} Hold (ManagementException managementException) {Console.WriteLine ("An error occurred:" + ManagementException.Message );}} /// & lt; Summary & gt; /// & lt; / summary & gt; /// & lt; Param name = "sender" & gt; /// Sender. /// & lt; / Param & gt; /// & lt; Ultimate name = "E" & gt; /// E. /// & lt; / Param & gt; Private Zero handleEvent (Object Sender, EventArrivedEventArgs E) {Console.WriteLine ("An Event Received."); // RegistryKeyChangeEvent is here; do something. } /// & lt; Summary & gt; /// & lt; / Summary & gt; Public static void main () {// bus events from above category ... WmiChangeEventTester receiveEvent = new (to say) to check for WmiChangeEventTester; }}}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -