本文整理汇总了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;
}
}
示例2: WatcherOnEventArrived
private void WatcherOnEventArrived(object sender, EventArrivedEventArgs eventArrivedEventArgs)
{
Console.WriteLine("Event arrived");
CheckKeyboardPlugging();
SetzeNumLock();
}
示例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;
}
}
}
示例4: OnRegistryWatcher_EventArrived
void OnRegistryWatcher_EventArrived(object sender, EventArrivedEventArgs e)
{
if (this.RegistryKeyChanged != null)
{
this.RegistryKeyChanged(this, new RegistryKeyChangedEventArgs(e.NewEvent));
}
}
示例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);
}
}
示例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));
}
示例7: HandleEvent
static void HandleEvent(object sender,
EventArrivedEventArgs e)
{
ManagementBaseObject targetInstance =
(ManagementBaseObject)e.NewEvent["TargetInstance"];
Console.WriteLine(targetInstance["Name"]);
}
示例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);
}
}
示例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());
}
}
示例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"]);
}
示例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");
}
}
示例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");
}
}
示例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));
}
示例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");
}
}
示例15: KeyValueChanged
private void KeyValueChanged(object sender, EventArrivedEventArgs e)
{
string programName = (string)Registry.GetValue(FullPath,
ValueName,
InvalidShow);
Console.Out.WriteLine("Found program {0}", programName);
}