当前位置: 首页>>代码示例>>C#>>正文


C# Management.EventArrivedEventArgs类代码示例

本文整理汇总了C#中System.Management.EventArrivedEventArgs的典型用法代码示例。如果您正苦于以下问题:C# EventArrivedEventArgs类的具体用法?C# EventArrivedEventArgs怎么用?C# EventArrivedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EventArrivedEventArgs类属于System.Management命名空间,在下文中一共展示了EventArrivedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: watcher_EventArrived

        private void watcher_EventArrived(object sender, EventArrivedEventArgs e)
        {
            string eventType = e.NewEvent.ClassPath.ClassName;
            WMI.Win32.Process proc = new WMI.Win32.Process(e.NewEvent["TargetInstance"] as ManagementBaseObject);

            switch (eventType)
            {
                case "__InstanceCreationEvent":
                    if (ProcessCreated != null)
                    {
                        ProcessCreated(proc);
                    }
                    break;

                case "__InstanceDeletionEvent":
                    if (ProcessDeleted != null)
                    {
                        ProcessDeleted(proc);
                    }
                    break;

                case "__InstanceModificationEvent":
                    if (ProcessModified != null)
                    {
                        ProcessModified(proc);
                    }
                    break;
            }
        }
开发者ID:zealoussnow,项目名称:OneCode,代码行数:29,代码来源:ProcessWatcher.cs

示例2: WatcherOnEventArrived

        private void WatcherOnEventArrived(object sender, EventArrivedEventArgs eventArrivedEventArgs)
        {
            Console.WriteLine("Event arrived");

            CheckKeyboardPlugging();
            SetzeNumLock();
        }
开发者ID:stemaj,项目名称:NumLockToggle,代码行数:7,代码来源:NumLockToggle.cs

示例3: DeviceRemovedEvent

 static void DeviceRemovedEvent(object sender, EventArrivedEventArgs e)
 {
     ManagementBaseObject instance = (ManagementBaseObject)e.NewEvent["TargetInstance"];
     Console.Write("Remove - ");
     var tmpQuery = new ManagementObjectSearcher("select Description,Name from Win32_LogicalDisk").Get();
     var currDrives = new List<string>();
     foreach (var drive in tmpQuery)
     {
         if (drive["Description"].ToString().Contains("Removable"))
         {
             currDrives.Add(drive["Name"].ToString());
         }
     }
     for (int i = 0; i < drives.Count; i++)
     {
         if (currDrives.IndexOf(drives[i]) == -1)
         {
             Console.WriteLine(drives[i]);
             //drives.RemoveAt(i);
             drives.Clear();
             drives.AddRange(currDrives);
             break;
         }
     }
 }
开发者ID:tqtam,项目名称:LUANVAN,代码行数:25,代码来源:Program.cs

示例4: OnRegistryWatcher_EventArrived

 void OnRegistryWatcher_EventArrived(object sender, EventArrivedEventArgs e)
 {
     if (this.RegistryKeyChanged != null)
     {
         this.RegistryKeyChanged(this, new RegistryKeyChangedEventArgs(e.NewEvent));
     }
 }
开发者ID:sreenandini,项目名称:test_buildscripts,代码行数:7,代码来源:RegistryWatcher.cs

示例5: ProcessStartEventArrived

 private void ProcessStartEventArrived(object sender, EventArrivedEventArgs e)
 {
     var processName = e.NewEvent.Properties["ProcessName"].Value.ToString();
     if (processName.ToLowerInvariant() == this.processName.ToLowerInvariant())
     {
         //var timeCreated = (ulong)e.NewEvent.Properties["TIME_CREATED"].Value;
         this.notifyAction(DateTime.Now);
     }
 }
开发者ID:sgnatonski,项目名称:slavapp,代码行数:9,代码来源:WMIWatcher.cs

示例6: DeviceArrived

 void DeviceArrived(object sender, EventArrivedEventArgs e)
 {
     List<Descriptor> arrivedDevices =
         Enumerator.AllDevices.Except(Devices).ToList();
     if (arrivedDevices.Count > 0)
         App.Invoke(() => Devices.AddRange(arrivedDevices));
 }
开发者ID:reinderien,项目名称:argscope,代码行数:7,代码来源:Hotplug.cs

示例7: HandleEvent

 static void HandleEvent(object sender, 
     EventArrivedEventArgs e)
 {
     ManagementBaseObject targetInstance =
         (ManagementBaseObject)e.NewEvent["TargetInstance"];
     Console.WriteLine(targetInstance["Name"]);
 }
开发者ID:lovebomb,项目名称:linkwithweb,代码行数:7,代码来源:WmiTest.cs

示例8: HandleProcessDeletion

        private void HandleProcessDeletion(object sender, EventArrivedEventArgs e)
        {
            //Console.WriteLine("Event arrived !");
            CLogger.WriteLog(ELogLevel.DEBUG, "Process killed arrived: # " + count++);
            try
            {
                // Get the Event object
                Win32ProcessInfo newInfo = new Win32ProcessInfo();
                newInfo.processID = Convert.ToInt32(e.NewEvent.Properties["ProcessId"].Value.ToString());
                newInfo.timeStamp = DateTime.Now;

                //CLogger.WriteLog(ELogLevel.DEBUG, managementObject.GetText(TextFormat.Mof));
                //MessageBox.Show("Here");
                //Win32ProcessInfo newInfo = processProcDeleteObject(managementObject);

                lock (killedProcessList)
                {
                    killedProcessList.Add(newInfo);
                }
            }
            catch (Exception ex)
            {
                //throw (new System.Exception(ex.Message));
                CLogger.WriteLog(ELogLevel.ERROR, ex.Message + "\n" + ex.StackTrace);
            }
        }
开发者ID:tkhurana,项目名称:File-Access-Monitor,代码行数:26,代码来源:ProcessDeleteWatcherAsync.cs

示例9: OnProcessStarted

        private void OnProcessStarted(object sender, EventArrivedEventArgs e)
        {
            try
                {
                    uint processId = (uint)(e.NewEvent["TargetInstance"] as ManagementBaseObject).GetPropertyValue("ProcessId");
                    string eventType = e.NewEvent.ClassPath.ClassName;

                    ProcessEventArgs args = new ProcessEventArgs(Process.GetProcessById((int)processId));
                    EventHandler<ProcessEventArgs> handler;

                    switch (eventType)
                    {
                        case "__InstanceCreationEvent":
                            handler = this.ProcessStarted;
                            if (handler != null)
                                this.ProcessStarted(this, args);
                            break;

                        case "__InstanceDeletionEvent":
                            break;

                        case "__InstanceModificationEvent":
                            break;

                        default:
                            break;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.ToString());
                }
        }
开发者ID:308465570,项目名称:FFXIV-Zodiac-Glass,代码行数:33,代码来源:ProcessObserver.cs

示例10: ReportEventMessage

 private void ReportEventMessage(EventArrivedEventArgs e)
 {
     ManagementBaseObject o = e.NewEvent; //__InstanceCreationEvent
     ManagementBaseObject mo = (ManagementBaseObject)o["TargetInstance"];//Win32_Process
     Console.WriteLine("Name={0},ExecPath={1},CommandLine={2}",
         mo["Name"], mo["ExecutablePath"], mo["CommandLine"]);
 }
开发者ID:buf1024,项目名称:filekeeper,代码行数:7,代码来源:Program.cs

示例11: OnFolderChanged

 private static void OnFolderChanged(object source, EventArrivedEventArgs e)
 {
     using (StreamWriter F = new StreamWriter("C:\\LABA4\\Laba-4.log", true))
     {
         F.WriteLine(DateTime.Now + " C:\\LABA4\\TEST changed");
     }
 }
开发者ID:katerinov,项目名称:Projects2,代码行数:7,代码来源:Service1.cs

示例12: OnRegChanged

 private static void OnRegChanged(object source, EventArrivedEventArgs e)
 {
     using (StreamWriter F = new StreamWriter("C:\\LABA4\\Laba-4.log", true))
     {
         F.WriteLine(DateTime.Now + " HKEY_LOCAL_MACHINE\\Software\\LABA4 changed");
     }
 }
开发者ID:katerinov,项目名称:Projects2,代码行数:7,代码来源:Service1.cs

示例13: HandleEvent

        private void HandleEvent(object sender, EventArrivedEventArgs e)
        {
            ManagementBaseObject info = e.NewEvent;

            log.Info("Event arrived ! " + info.ClassPath);
            log.Debug(info.GetText(TextFormat.Mof));
        }
开发者ID:HwangBae,项目名称:hoo-eye-relaxant,代码行数:7,代码来源:EventWatcherAsync.cs

示例14: OnDNSCacheChanged

 private static void OnDNSCacheChanged(object source, EventArrivedEventArgs e)
 {
     using (StreamWriter F = new StreamWriter("C:\\LABA4\\Laba-4.log", true))
     {
         F.WriteLine(DateTime.Now + " DNSCache.exe proccess changed");
     }
 }
开发者ID:katerinov,项目名称:Projects2,代码行数:7,代码来源:Service1.cs

示例15: KeyValueChanged

 private void KeyValueChanged(object sender, EventArrivedEventArgs e)
 {
     string programName = (string)Registry.GetValue(FullPath,
         ValueName,
         InvalidShow);
     Console.Out.WriteLine("Found program {0}", programName);
 }
开发者ID:njayawa,项目名称:ProgramServer,代码行数:7,代码来源:RegistryWatcher.cs


注:本文中的System.Management.EventArrivedEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。