C#中利用CreateToolhelp32Snapshot遍历系统进程
来源:互联网 发布:运营要会美工吗 编辑:程序博客网 时间:2024/06/01 09:20
private void button1_Click(object sender, EventArgs e)
{
IntPtr handle=CreateToolhelp32Snapshot(0x2, 0);
if ((int)handle > 0)
{
ProcessEntry32 pe32 = new ProcessEntry32();
pe32.dwSize = (uint)Marshal.SizeOf(pe32);
int bMore = Process32First(handle, ref pe32);
while (bMore == 1)
{
IntPtr temp = Marshal.AllocHGlobal((int)pe32.dwSize);
Marshal.StructureToPtr(pe32, temp, true);
ProcessEntry32 pe=(ProcessEntry32)Marshal.PtrToStructure(temp, typeof(ProcessEntry32));
Marshal.FreeHGlobal(temp);
list.Add(pe);
bMore = Process32Next(handle, ref pe32);
}
CloseHandle(handle);
foreach(ProcessEntry32 p in list)
richTextBox1.AppendText(p.szExeFile+"/r/n");
}
}
[DllImport("KERNEL32.DLL ")]
public static extern IntPtr CreateToolhelp32Snapshot(uint flags, uint processid);
[DllImport("KERNEL32.DLL ")]
public static extern int CloseHandle(IntPtr handle);
[DllImport("KERNEL32.DLL ")]
public static extern int Process32First(IntPtr handle, ref ProcessEntry32 pe);
[DllImport("KERNEL32.DLL ")]
public static extern int Process32Next(IntPtr handle, ref ProcessEntry32 pe);
}
=========================================================================
[StructLayout(LayoutKind.Sequential)]
public struct ProcessEntry32
{
public uint dwSize;
public uint cntUsage;
public uint th32ProcessID;
public IntPtr th32DefaultHeapID;
public uint th32ModuleID;
public uint cntThreads;
public uint th32ParentProcessID;
public int pcPriClassBase;
public uint dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=260)]
public string szExeFile;
};
}
- C#中利用CreateToolhelp32Snapshot遍历系统进程
- 获取系统进程 CreateToolhelp32Snapshot
- CreateToolhelp32Snapshot获取系统进程
- 枚举当前系统进程--CreateToolhelp32Snapshot
- Wpf 遍历系统进程 C#
- 【转】通过CreateToolhelp32Snapshot函数获得系统中当前运行的进程信息
- 用CreateToolhelp32Snapshot/Process32First/Process32Next API枚举系统进程
- 用CreateToolhelp32Snapshot/Process32First/Process32Next API枚举系统进程
- 用CreateToolhelp32Snapshot/Process32First/Process32Next API枚举系统进程
- 用CreateToolhelp32Snapshot/Process32First/Process32Next API枚举系统进程 .
- CreateToolhelp32Snapshot枚举进程
- CreateToolhelp32Snapshot枚举进程
- CreateToolhelp32Snapshot枚举进程
- CreateToolhelp32Snapshot枚举进程
- CreateToolhelp32Snapshot枚举进程
- CreateToolhelp32Snapshot 进程快照
- CreateToolhelp32Snapshot枚举进程
- CreateToolhelp32Snapshot枚举进程
- BBS之旅
- 安装oracle11g时 su: /bin/bash: Too many open files in system
- EasyAServer 0.3 bate2 版放出。
- 国米夺冠 我不伤心
- 时间的灰烬之与狼共舞的羊
- C#中利用CreateToolhelp32Snapshot遍历系统进程
- 用扩展的欧几里德算法求最大公约数以及逆元
- What Are the Gmail Exchange ActiveSync Settings?
- 5月25天氣晴
- .Net承载了微软太多的梦想
- 业精于勤而荒于嬉 行成于思而毁于随
- 原來
- 符号翻译
- java中获取当前路径的方法