Maximus Posted September 9, 2011 Report Share Posted September 9, 2011 Salut , am gasit acest cod pe net si nu inteleg de ce se inchide executabilul imediat dupa ce il deschid , intentia mea este sa monitorizez HKEY_USERS\SID\Software\Yahoo\pager\profiles\ID\Custom Msgs 1_W.In fisierul reg_mon.cfg este o singura linie : idul meu.Folosesc Microsoft Visual Studio 2010asta este codu :namespace WmiExample{ using System; using System.Management; using System.Security.Principal; using System.IO; public class WmiChangeEventTester { public WmiChangeEventTester() { try { string a; string b; a = Environment.UserName; b = Environment.MachineName; WindowsIdentity identity = WindowsIdentity.GetCurrent(); string filePath = @"reg_mon.cfg"; string line; StreamReader file = null; file = new StreamReader(filePath); line = file.ReadLine(); WqlEventQuery query = new WqlEventQuery( "SELECT * FROM RegistryValueChangeEvent WHERE " + "Hive = 'HKEY_USERS'" + @"AND KeyPath = '" + identity.User + "\\Software\\Yahoo\\pager\\profiles\\" + line + "\\Custom Msgs' AND ValueName='1_W'"); ManagementEventWatcher watcher = new ManagementEventWatcher(query); Console.WriteLine("Waiting for an event..."); Console.WriteLine("AND KeyPath = '"+ identity.User +"\\Software\\Yahoo\\pager\\profiles\\"+ line +"\\Custom Msgs' AND ValueName='1_W'"); watcher.EventArrived += new EventArrivedEventHandler(HandleEvent); watcher.Start(); System.Threading.Thread.Sleep(100000000); watcher.Stop(); } catch (ManagementException managementException) { Console.WriteLine("An error occurred: " + managementException.Message); } } private void HandleEvent(object sender, EventArrivedEventArgs e) { Console.WriteLine("Received an event."); } public static void Main() { WmiChangeEventTester receiveEvent = new WmiChangeEventTester(); } }}Nu am facut nici un fel de curs,am citit doar ceva pagini de pe net si GOOGLE foarte mult.As fi recunoscator daca m-ar ajuta cineva Quote Link to comment Share on other sites More sharing options...