C#获取运行程序的进程ID
2016-06-16 22:25
513 查看
C#获取运行程序的进程ID
[DllImport("User32.dll", CharSet = CharSet.Auto)] public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID); [DllImport("user32.dll", EntryPoint = "FindWindow")] private extern static IntPtr FindWindow(string lpClassName, string lpWindowName); static void Main(string[] args) { IntPtr hwnd = FindWindow(null, "计算器"); if (hwnd != IntPtr.Zero) { int calcID; //获取进程ID GetWindowThreadProcessId(hwnd, out calcID); } }
相关文章推荐
- c#CheckedListBox单选多选个数限制问题
- C# 读取快捷方式指向的文件
- 转 C# 装箱和拆箱[整理]
- c#checkedListBox设置限制选项个数的问题
- C#MVC中Controler的自定义属性使用
- 练习、C# 结构体、冒泡排序
- C#中的代理
- C# 生成随机索引列表
- 关于C#对图片部分操作(水印、透明度)
- U3D结合第三方库ICSharpCode.SharpZipLib 实现文件夹打包解包
- C# UDP收发请求工具类
- C# 多线程是否结束可通过线程池可以判断
- VS2015中C#版本6.0的新特性 你需要知道
- C#中lambda表达式浅析
- C#中数组、ArrayList和List三者的区别
- [置顶] C# 如何利用反射,将字符串转化为类名并调用类中方法
- 自定义热键的代码(C#)
- C#套接字Socket编程之最简单通信
- C# DateTime 格式化 奇怪问题!
- C# TransactionScope 使用