示例#1
0
 private void listService_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         if (listService.SelectedItems.Count > 0)
         {
             ListViewItem item = listService.SelectedItems[0];
             ScTag        t    = item.Tag as ScTag;
             MSCM_ShowMenu(Handle, t.name, t.runningState, t.startType, t.binaryPathName, 0, 0);
         }
     }
 }
示例#2
0
 private void listService_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Apps)
     {
         if (listService.SelectedItems.Count > 0)
         {
             ListViewItem item = listService.SelectedItems[0];
             Point        p    = item.Position; p.X = 0;
             p = listService.PointToScreen(p);
             ScTag t = item.Tag as ScTag;
             MSCM_ShowMenu(Handle, t.name, t.runningState, t.startType, t.binaryPathName, p.X, p.Y);
         }
     }
 }
示例#3
0
        private void ScMgrIEnumServicesCallBack(IntPtr dspName, IntPtr scName, uint scType, uint currentState, uint dwProcessId, bool syssc,
                                                uint dwStartType, IntPtr lpBinaryPathName, IntPtr lpLoadOrderGroup, bool add)
        {
            if (add)
            {
                ListViewItem li = new ListViewItem(Marshal.PtrToStringUni(scName));
                ScTag        t  = new ScTag();
                t.name           = li.Text;
                t.runningState   = currentState;
                t.startType      = scType;
                t.binaryPathName = Marshal.PtrToStringUni(lpBinaryPathName);
                li.SubItems.Add(dwProcessId == 0 ? "" : dwProcessId.ToString());
                li.Tag = t;
                if (dwProcessId != 0)
                {
                    scValidPid.Add(dwProcessId);
                    runningSc.Add(new ScItem(Convert.ToInt32(dwProcessId), Marshal.PtrToStringUni(lpLoadOrderGroup), Marshal.PtrToStringUni(scName), Marshal.PtrToStringUni(dspName)));
                }
                li.SubItems.Add(Marshal.PtrToStringUni(dspName));
                switch (currentState)
                {
                case 0x0001:
                case 0x0003: li.SubItems.Add(LanuageFBuffers.Str_StatusStopped); break;

                case 0x0002:
                case 0x0004: li.SubItems.Add(LanuageFBuffers.Str_StatusRunning); break;

                case 0x0006:
                case 0x0007: li.SubItems.Add(LanuageFBuffers.Str_StatusPaused); break;

                default: li.SubItems.Add(""); break;
                }
                li.SubItems.Add(Marshal.PtrToStringUni(lpLoadOrderGroup));
                switch (dwStartType)
                {
                case 0x0000: li.SubItems.Add(LanuageFBuffers.Str_DriverLoad); break;

                case 0x0001: li.SubItems.Add(LanuageFBuffers.Str_DriverLoad); break;

                case 0x0002: li.SubItems.Add(LanuageFBuffers.Str_AutoStart); break;

                case 0x0003: li.SubItems.Add(LanuageFBuffers.Str_DemandStart); break;

                case 0x0004: li.SubItems.Add(LanuageFBuffers.Str_Disabled); break;

                case 0x0080: li.SubItems.Add(""); break;

                default: li.SubItems.Add(""); break;
                }
                switch (scType)
                {
                case 0x0002: li.SubItems.Add(LanuageFBuffers.Str_FileSystem); break;

                case 0x0001: li.SubItems.Add(LanuageFBuffers.Str_KernelDriver); break;

                case 0x0010: li.SubItems.Add(LanuageFBuffers.Str_UserService); break;

                case 0x0020: li.SubItems.Add(LanuageFBuffers.Str_SystemService); break;

                default: li.SubItems.Add(""); break;
                }

                string path = Marshal.PtrToStringUni(lpBinaryPathName);
                if (!MFM_FileExist(path))
                {
                    StringBuilder spath = new StringBuilder(260);
                    if (MCommandLineToFilePath(path, spath, 260))
                    {
                        path = spath.ToString();
                    }
                }

                bool hightlight = false;
                if (!string.IsNullOrEmpty(path) && MFM_FileExist(path))
                {
                    li.SubItems.Add(path);
                    StringBuilder exeCompany = new StringBuilder(256);
                    if (MGetExeCompany(path, exeCompany, 256))
                    {
                        li.SubItems.Add(exeCompany.ToString());
                        if (mainSettings.HighlightNoSystem && exeCompany.ToString() != ConstVals.MICROSOFT)
                        {
                            hightlight = true;
                        }
                    }
                    else if (mainSettings.HighlightNoSystem)
                    {
                        hightlight = true;
                    }
                }
                else
                {
                    li.SubItems.Add(path);
                    li.SubItems.Add(LanuageFBuffers.Str_FileNotExist);
                    if (mainSettings.HighlightNoSystem)
                    {
                        hightlight = true;
                    }
                }
                if (hightlight)
                {
                    li.ForeColor = Color.Blue;
                    foreach (ListViewItem.ListViewSubItem s in li.SubItems)
                    {
                        s.ForeColor = Color.Blue;
                    }
                }
                listService.Items.Add(li);
            }
            else if (updateScItem != null)
            {
                ScTag t = (ScTag)updateScItem.Tag;
                t.runningState = currentState;
                t.startType    = scType;
                if (dwProcessId != 0)
                {
                    scValidPid.Add(dwProcessId);
                    updateScItem.SubItems[1].Text = dwProcessId.ToString();
                }
                else
                {
                    if (updateScItem.SubItems[1].Text != "")
                    {
                        uint oldpid = UInt32.Parse(updateScItem.SubItems[1].Text);
                        if (scValidPid.Contains(oldpid))
                        {
                            scValidPid.Remove(oldpid);
                        }
                    }
                    updateScItem.SubItems[1].Text = "";
                }
                switch (currentState)
                {
                case 0x0001:
                case 0x0003: updateScItem.SubItems[3].Text = LanuageFBuffers.Str_StatusStopped; break;

                case 0x0002:
                case 0x0004: updateScItem.SubItems[3].Text = LanuageFBuffers.Str_StatusRunning; break;

                case 0x0006:
                case 0x0007: updateScItem.SubItems[3].Text = LanuageFBuffers.Str_StatusPaused; break;

                default: updateScItem.SubItems[3].Text = ""; break;
                }
                switch (dwStartType)
                {
                case 0x0000: updateScItem.SubItems[5].Text = LanuageFBuffers.Str_DriverLoad; break;

                case 0x0001: updateScItem.SubItems[5].Text = LanuageFBuffers.Str_DriverLoad; break;

                case 0x0002: updateScItem.SubItems[5].Text = LanuageFBuffers.Str_AutoStart; break;

                case 0x0003: updateScItem.SubItems[5].Text = LanuageFBuffers.Str_DemandStart; break;

                case 0x0004: updateScItem.SubItems[5].Text = LanuageFBuffers.Str_Disabled; break;

                case 0x0080: updateScItem.SubItems[5].Text = ""; break;

                default: updateScItem.SubItems[5].Text = ""; break;
                }
                updateScItem = null;
            }
        }