Tôi muốn xử lý điều này khác nhau, tức là. xác định xem tôi có quyền truy cập hay không.Process.MainModule -> "Truy cập bị từ chối"
Có thể xem bạn có quyền truy cập vào mô-đun chính hay không?
foreach (Process p in Process.GetProcesses())
{
try
{
//This throws error for some processes.
if (p.MainModule.FileName.ToLower().EndsWith(ExeName, StringComparison.CurrentCultureIgnoreCase))
{
//Do some stuff
}
}
catch (Exception)
{
//Acess denied
}
}
Ở đây chúng tôi lại tiếp tục. Có một cái nhìn @ http://stackoverflow.com/questions/2774527/access-denied-while-using-system-diagnostics-process – leppie