cc 公主说的我早试过了 public static string RunningInstance() { Process[] processes = Process.GetProcesses(); string s = null; foreach (Process p in processes) { s += p.WorkingSet + p.ProcessName + "\r\n" + p.StartInfo.FileName + " " + p.StartInfo.Arguments; } return s; }结果是p.StartInfo 里都是空值,因为StartInfo 是要传递的属性而不是用来获取已存在进程的属性
搞了半天终于找到一个可用的:using System; using System.Management;namespace ArLi.CommonPrj { public class GetCommandLineEx { public static readonly System.Version myVersion = new System.Version(1,1); /// <summary> /// LocalHost /// </summary> public static string CommandLine_WMI(){ System.Management.ManagementScope ms = new System.Management.ManagementScope(@"\\.\root\cimv2"); System.Management.ObjectQuery oq = new System.Management.ObjectQuery("select * from win32_process"); ManagementObjectSearcher query = new ManagementObjectSearcher(ms,oq); ManagementObjectCollection moc = query.Get(); string s = ""; foreach(ManagementObject mo in moc) { s += (string)mo["CommandLine"] + "\r\n"; } return s; } } }但是这个CommandLine Data type: string Access type: Read-onlyCommand line used to start a specific process, if applicable. This property is new for Windows XP.这下可惨了,我的程序要求有win98 哩最少也要win2k 能跑呀,为为,大家一起帮帮忙想想啊
翻烂了WMI 也没找到更好的,而且根据 sysinternals 的 Process Explorer 的函数引用分析它使用的肯定不是wmi 而最有嫌疑的就是 getcommandline,可偶就是搞不出来,难道sysinternals 知道它有隐藏参数;-(
you probably have to work with unsafe code, see this guy's suggestion:http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=F07Z5.83483%24lR2.2679507%40afrodite.telenet-ops.be
3q saucer,但是你的地址里面最重要的"See http://www.codepile.com/tric14.shtml for details"i can'n open... ;-(
seehttp://fravia.anticrack.de/natz_mp2.htm
http://www.csdn.net/Develop/Article/18/18722.shtm
This sample demonstrates how to get the command line another process was started with: http://mvps.org/win32/processes/remthread.html
String cmd = process.StartInfo.FileName + " " + process.StartInfo.Arguments;
Process[] processes = Process.GetProcesses();
string s = null; foreach (Process p in processes) {
s += p.WorkingSet + p.ProcessName + "\r\n" + p.StartInfo.FileName + " " + p.StartInfo.Arguments;
} return s;
}结果是p.StartInfo 里都是空值,因为StartInfo 是要传递的属性而不是用来获取已存在进程的属性
using System.Management;namespace ArLi.CommonPrj {
public class GetCommandLineEx { public static readonly System.Version myVersion = new System.Version(1,1); /// <summary>
/// LocalHost
/// </summary>
public static string CommandLine_WMI(){
System.Management.ManagementScope ms = new System.Management.ManagementScope(@"\\.\root\cimv2");
System.Management.ObjectQuery oq = new System.Management.ObjectQuery("select * from win32_process");
ManagementObjectSearcher query = new ManagementObjectSearcher(ms,oq); ManagementObjectCollection moc = query.Get(); string s = ""; foreach(ManagementObject mo in moc) {
s += (string)mo["CommandLine"] + "\r\n";
}
return s;
}
}
}但是这个CommandLine
Data type: string
Access type: Read-onlyCommand line used to start a specific process, if applicable. This property is new for Windows XP.这下可惨了,我的程序要求有win98 哩最少也要win2k 能跑呀,为为,大家一起帮帮忙想想啊
http://contextfree.net/wangyg/tech/myIDE.htm
http://zpcity.com/arli/commonprj/cls_GetCommandLineEx.cs可是还是没法用API 做到,WMI 做总是不好多个服务依存而且还必须是xp 以上,里面的CommandLine_API 哪位帮忙写一下!急用
http://mvps.org/win32/processes/remthread.html