Exemple #1
0
        static void Main(string[] args)
        {
            WMIHelper helper = new WMIHelper("root\\CimV2");

            //List<NetworkAdapterConfiguration> interfaces = helper.Query<NetworkAdapterConfiguration>().ToList();

            Printer printer = helper.QueryFirstOrDefault <Printer>();

            //List<Printer> printers = helper.Query<Printer>().ToList();

            //foreach (Printer p in printers)
            //{
            //    p.RenamePrinter("Newly renamed printer");
            //}

            //Output outp = new Output
            //{
            //    PanelID = 10,
            //    ReaderID = 1,
            //    Hostname = "ONGUARD01",
            //    Name = "ONGUARD01"
            //};

            //outp.Activate();

            List <Process> processes = helper.QueryAsync <Process>().Result.ToList();

            foreach (Process p in processes)
            {
                dynamic      d  = p.GetOwnerSid();
                ProcessOwner po = p.GetOwner();
                //int res = p.AttachDebugger();
            }

            //var dynDevices = helper.Query("SELECT * FROM Win32_PnPEntity");

            //var processors = helper.Query<Processor>();

            //List<Processor> procesors = helper.Query<Processor>().ToList();

            //List<Device> devices = helper.Query<Device>().ToList()
            //    .Where(p => (p.Name ?? "")
            //    .Contains("Intel")).ToList();

            //foreach (Device d in devices)
            //{
            //    Console.WriteLine(d.Name);
            //}

            //Person person = new Person
            //{
            //    FirstName = "John",
            //    Lastname = "Doe",
            //    DocumentNumber = "9995",
            //    Segment = -1,
            //    Age = 43
            //};

            //helper.AddInstance(person);

            //Person queryPersonSingle = helper.Query<Person>("SELECT * FROM Lnl_Cardholder WHERE LASTNAME = 'Doe Modified'").SingleOrDefault();

            //queryPersonSingle.Lastname = "Doe Modified";

            //helper.UpdateInstance(queryPersonSingle);

            //List<Person> queryPerson = helper.Query<Person>("SELECT * FROM Lnl_Cardholder WHERE LASTNAME = 'Lopez'").ToList();

            //WMIWatcher watcher = new WMIWatcher("root\\CimV2", "SELECT * FROM Win32_ProcessStartTrace", typeof(Process));
            //WMIWatcher watcher = new WMIWatcher("root\\CimV2", "SELECT * FROM Win32_ProcessStartTrace");
            //watcher.WMIEventArrived += Watcher_WMIEventArrived;

            Console.ReadLine();
        }