Process[] processlist = Process.GetProcesses();
foreach (Process proc in processlist) {
Console.Write(proc.MainModule.FileName);
}
这给了 Win32Exception是未处理的访问被拒绝
如何解决这一问题?我试着运行它作为ADM,但它得到同样的错误。在此先感谢!
it give an Win32Exception was unhandled access denied
how to fix this? I tried run it as adm but it get same error. Thanks in advance!
有,你是不是允许访问即使管理员某些进程。您可以捕获该异常,并坚持下去:
There are some processes that you aren't allowed to access even as administrator. You can trap the exception and keep going:
foreach (Process proc in processlist)
{
try
{
Console.WriteLine(proc.MainModule.FileName);
}
catch (Win32Exception e)
{
Console.WriteLine(proc.ToString() + " " + e.Message);
}
}