private void getPrecess() { process = Process.GetProcesses(); processItems.Clear(); foreach (var item in process) { processItems.Add(new ProcessItem(item)); } gcProcess.DataSource = processItems; windows = GetProcesses.GetAllWindows(); gcRun.DataSource = windows; }
private void Form1_Load(object sender, EventArgs e) { getPrecess(); timer1.Enabled = true; timer1.Interval = 3000; int ff = 0; List <string> FileNames = new List <string>(); foreach (var wnd in GetProcesses.GetAllWindows()) { GetProcesses.GetWindowThreadProcessId(wnd.handle, out ff); FileNames.Add(Process.GetProcessById(ff).MainModule.ModuleName); } }
public static List <GetProcesses> GetAllWindows() { List <GetProcesses> windows = new List <GetProcesses>(); StringBuilder buffer = new StringBuilder(100); EnumWindows(delegate(IntPtr hwnd, Int32 lParam) { if ((GetWindowLongA(hwnd, GWL_STYLE) & DESIRED_WS) == DESIRED_WS) { GetWindowText(hwnd, buffer, buffer.Capacity); GetProcesses wnd = new GetProcesses(); wnd.handle = hwnd; wnd.title = buffer.ToString(); windows.Add(wnd); } return(true); }, 0); return(windows); }