Пример #1
0
        private void RefreshProcessList()
        {
            SCROLLBARINFO s = new SCROLLBARINFO {
                cbSize = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(SCROLLBARINFO))
            };

            GetScrollBarInfo(lvwProcesses.Handle, unchecked ((int)0xFFFFFFFA), ref s);
            uint[]        processIds;
            IntPtr        snapshotHandle;
            MODULEENTRY32 moduleEntry32;
            ListViewItem  listViewItem;
            string        t;
            bool          isDotNetProcess;
            bool          is64;

            lvwProcesses.Items.Clear();
            processIds = Process32.GetAllProcessIds();
            if (processIds == null)
            {
                return;
            }
            moduleEntry32 = MODULEENTRY32.Default;
            foreach (uint processId in processIds)
            {
                if (processId == 0)
                {
                    continue;
                }
                snapshotHandle = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, processId);
                if (snapshotHandle == INVALID_HANDLE_VALUE)
                {
                    continue;
                }
                if (!Module32First(snapshotHandle, ref moduleEntry32))
                {
                    continue;
                }
                listViewItem = new ListViewItem(moduleEntry32.szModule);
                listViewItem.SubItems.Add(processId.ToString());
                listViewItem.SubItems.Add(moduleEntry32.szExePath);
                isDotNetProcess = false;
                while (Module32Next(snapshotHandle, ref moduleEntry32))
                {
                    if ((t = moduleEntry32.szModule.ToUpperInvariant()) == "MSCORJIT.DLL" || t == "MSCOREE.DLL" || t == "MSCORWKS.DLL" || t == "CLR.DLL" || t == "CLRJIT.DLL")
                    {
                        listViewItem.BackColor = Cache.DotNetColor;
                        isDotNetProcess        = true;
                        if (Cache.Is64BitOperatingSystem && Is64BitPE(moduleEntry32.szExePath, out is64) && !is64)
                        {
                            listViewItem.Text += " (32 位)";
                        }
                        break;
                    }
                }
                if (Cache.Is64BitOperatingSystem && !isDotNetProcess && Is64BitPE(listViewItem.SubItems[2].Text, out is64) && !is64)
                {
                    listViewItem.Text += " (32 位)";
                }
                if (!mnuOnlyDotNetProcess.Checked || isDotNetProcess)
                {
                    lvwProcesses.Items.Add(listViewItem);
                }
            }
            lvwProcesses.AutoResizeColumns(false);
        }
Пример #2
0
 public static extern bool GetScrollBarInfo(IntPtr hwnd, int idObject, ref SCROLLBARINFO psbi);