在 .NET 中获取进程信息 [英] Getting process information in .NET

查看:100
本文介绍了在 .NET 中获取进程信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重复这个问题.

update - 这不是完全重复的.查看我的解决方案.

update - This is not an exact duplicate. See my solution.

我在进程资源管理器中看到一个 java.exe 进程,双击它会给我它的工作目录 &启动命令行参数.

I see a java.exe process in process explorer, and double clicking it gives me its working directory & starting command line arguments.

在 .NET 中,我运行以下代码并获得一个具有相同 PID 的进程,但上述字段为空.显然,已记录在案.

From .NET, I run the following code and get a process with the same PID but the above fields are empty. Apparently, this is documented.

foreach (Process process in Process.GetProcessesByName("java"))
{ 
  ...
}

那么如何获得正确的 startinfo 字段值,而无需手动查看进程内存(换句话说 - 我想从某处窃取此代码而不是自己破解进程内存).

So how do I get the correct startinfo field values, without peeking into process memory by hand (in other words - I'd like to steal this code from somewhere instead of hack the process memory myself).

推荐答案

我写了一些代码来完成这个(博客文章直接链接压缩).

I wrote some code the accomplish this (blog post and direct link to zip).

简而言之:这个问题帮助很大.我将 CodeProject 代码包装在一个命令行实用程序中,然后是一个 C# 包装器.

In short: this question helped a lot. I took the CodeProject code and wrapped it in a command line utility and then a C# wrapper.

这篇关于在 .NET 中获取进程信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆