我想處理這個不同, 即。確定我是否有權訪問。Process.MainModule - >「訪問被拒絕」
是否可以查看您是否可以訪問主模塊?
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
}
}
這裏我們再次去。看看@ http://stackoverflow.com/questions/2774527/access-denied-while-using-system-diagnostics-process – leppie