private void procEvents_ProcessExited(object sender, EventArgsValue <Process> e)
        {
            string exitCode = "";

            try { exitCode = " Code " + e.Value.ExitCode.ToString(); } catch { }
            this.Log.LogLineDate("A process has exited: " + e.Value.ProcessName + " (" + e.Value.Id + ")" + exitCode, Trigger.Log.Type.ProcessesEvent);
        }
Пример #2
0
 internal static void Main_MessageReceived(object sender, EventArgsValue<Message> e)
 {
     if (e.Value.Msg != (int)Classes.System.WindowsMessages.WM_POWERBROADCAST)
         return;
     PBT wParam = (PBT)e.Value.WParam.ToInt32();
     switch (wParam)
     {
         case PBT.POWERSETTINGCHANGE:
             PowerBroadcast_Setting pbs = (PowerBroadcast_Setting)Marshal.PtrToStructure(e.Value.LParam, typeof(PowerBroadcast_Setting));
             PowerScheme oldPlan = (PowerScheme)oldStaticValues[EventType.PowerSchemeChanged];
             PowerScheme newPlan = Status.Power.ActivePowerScheme;
             if (oldPlan == newPlan)
                 return;
             if (OnPowerSchemeChanged != null)
                 OnPowerSchemeChanged(null, new EventArgsValues<PowerScheme>(oldPlan, newPlan));
             oldStaticValues[EventType.PowerSchemeChanged] = newPlan;
             break;
     }
 }
Пример #3
0
        internal static void Main_MessageReceived(object sender, EventArgsValue<Message> e)
        {
            if (e.Value.Msg != (int)WindowsMessages.WM_DEVICECHANGE || e.Value.LParam == IntPtr.Zero)
                return;

            DEV_BROADCAST_VOLUME dbcv = (DEV_BROADCAST_VOLUME)Marshal.PtrToStructure(e.Value.LParam, typeof(DEV_BROADCAST_VOLUME));
            if (dbcv.dbcv_devicetype != (int)DBT.DEVTYP_VOLUME)
                return;		// we were not even allowed to transform to DEV_BROADCAST_VOLUME =) But who cares...

            switch ((DBT)((int)e.Value.WParam))
            {
                #region case DBT.DEVICEARRIVLE:
                case DBT.DEVICEARRIVAL:
                    StorageDisk device = StorageDisk.FromUnitMask(dbcv.dbcv_unitmask);
                    ((List<StorageDisk>)oldStaticValues[EventType.DeviceRemoved]).Add(device);
                    if (dbcv.dbcv_flags == 1 /*DBFT_MEDIA*/)
                    {
                        if (OnMediaInserted != null)
                            OnMediaInserted(null, new EventArgsValue<Classes.Device.Device>(device));
                    }
                    else if (dbcv.dbcv_flags == 2 /*DBFT_NET*/)
                    {
                        if (OnNetworkVolumeArrived != null)
                            OnNetworkVolumeArrived(null, new EventArgsValue<Classes.Device.Device>(device));
                    }
                    else
                    {
                        if (OnDeviceArrived != null)
                            OnDeviceArrived(null, new EventArgsValue<Classes.Device.Device>(device));
                    }
                    break;
                #endregion
                #region case DBT.DEVICEQUERYREMOVE:
                case DBT.DEVICEQUERYREMOVE:
                    throw new NotImplementedException("\"Device Query remove\" is not implemented");
                #endregion
                #region case DBT.DEVICEQUERYREMOVEFAILED:
                case DBT.DEVICEQUERYREMOVEFAILED:
                    throw new NotImplementedException("\"Device Query remove failed\" is not implemented");
                #endregion
                #region case DBT.DEVICEREMOVECOMPLETE:
                case DBT.DEVICEREMOVECOMPLETE:
                    if (OnDeviceRemoved == null)
                        break;
                    char removedDiskLetter = StorageDisk.FirstDriveFromMask(dbcv.dbcv_unitmask);
                    List<StorageDisk> oldDisks = (List<StorageDisk>)oldStaticValues[EventType.DeviceRemoved];
                    foreach (StorageDisk oldDisk in oldDisks)
                    {
                        if (oldDisk.DriveLetters.Contains(removedDiskLetter))
                        {
                            OnDeviceRemoved(null, new EventArgsValue<Classes.Device.Device>(oldDisk));
                            oldDisks.Remove(oldDisk);
                            break;
                        }
                    }
                    break;
                #endregion
            }
        }
 private void procEvents_ProcessCreated(object sender, EventArgsValue <Process> e)
 {
     try { this.Log.LogLineDate("A new process was created: " + e.Value.ProcessName + " (" + e.Value.Id + ")", Trigger.Log.Type.ProcessesEvent); }
     catch { this.Log.LogLineDate("A new process was created", Trigger.Log.Type.ProcessesEvent); };
 }
 private void procEvents_ProcessExited(object sender, EventArgsValue<Process> e)
 {
     string exitCode = "";
     try { exitCode = " Code " + e.Value.ExitCode.ToString(); } catch { }
     this.Log.LogLineDate("A process has exited: " + e.Value.ProcessName + " (" + e.Value.Id + ")" + exitCode, Trigger.Log.Type.ProcessesEvent);
 }
 private void procEvents_ProcessCreated(object sender, EventArgsValue<Process> e)
 {
     try { this.Log.LogLineDate("A new process was created: " + e.Value.ProcessName + " (" + e.Value.Id + ")", Trigger.Log.Type.ProcessesEvent); }
     catch { this.Log.LogLineDate("A new process was created", Trigger.Log.Type.ProcessesEvent); };
 }