Wpf 遍历系统进程 C#
2013-01-12 10:26
162 查看
Kernel32 http://[/code]
点击打开链接using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace THEnumProcesses { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_Loaded(object sender, RoutedEventArgs e) { var handle = Kernel32.CreateToolhelp32Snapshot(0x2, 0); var list = new List<Kernel32.ProcessEntry32>(); if ((int)handle > 0) { var pe32 = new Kernel32.ProcessEntry32(); pe32.dwSize = (uint)Marshal.SizeOf(pe32); int bMore = Kernel32.Process32First(handle, ref pe32); while (bMore == 1) { var temp = Marshal.AllocHGlobal((int)pe32.dwSize); Marshal.StructureToPtr(pe32, temp, true); var pe = (Kernel32.ProcessEntry32)Marshal.PtrToStructure(temp, typeof(Kernel32.ProcessEntry32)); Marshal.FreeHGlobal(temp); list.Add(pe); bMore = Kernel32.Process32Next(handle, ref pe32); } Kernel32.CloseHandle(handle); listView1.ItemsSource = list.Select(obj=>new { PID = obj.th32ProcessID, 进程名 = obj.szExeFile, }).ToList(); } } } }
相关文章推荐
- C#中利用CreateToolhelp32Snapshot遍历系统进程
- C#遍历系统进程的方法
- C# 获取系统当前进程列表
- C#开发WPF/Silverlight动画及游戏系列教程(Game Tutorial):(二十八) 经典式属性设计及完美的物理攻击系统
- 编写模块遍历系统中的进程
- C#小技巧系列之三:获取系统进程信息
- C#遍历进程获取主窗口句柄
- 编写模块遍历系统中的进程(续)
- C#获取系统服务+进程+启动时间
- C#开发WPF/Silverlight动画及游戏系列教程(Game Tutorial):(二十八) 经典式属性设计及完美的物理攻击系统
- C#小技巧系列之三:获取系统进程信息
- proc文件系统_每进程信息形成原理、目录遍历方式、位图查找
- WPF TreeView 后台C#选中指定的Item, 需要遍历
- 加载内核模块,实现新的系统调用:遍历系统当前所有进程的任务描述符,并将pid组织成树状结构显示
- C#遍历系统所安装的打印机,使用WMI方式获取打印机的所有属性
- C#得到系统进程和结束某个指定的进程
- C#查询系统运行进程,关闭进程,记录键盘按键记录
- windows api学习笔记-遍历系统进程,获取进程名称和ID(进程快照)
- c#关闭系统进程以及如何调用cmd并执行命令
- 毕业设计项目展示作品六:WPF、C#船舶动力定位模拟系统