What I'm trying to do is get the processing time per process using a method
//Current Method
public string GetRunningTime(Process p){
string returnString = "00:00:00:00.00";//DD:HH;MM;SS.ff
try{
returnString = DateTime.Now.Subtract(p.StartTime).ToString(@"dd\.hh\:mm\:ss\.ff");//Time now - StartTime. ToString With format
}catch(Exception){}//Catchs System.ComponentModel.Win32Exception: 'Access is denied'
return returnString;//returns the string.
}
And the try-catch is the only way I could do the math without crashing. I was wondering if there is a way to know if the program has access to view the StartTime. so it would know not to do the math.
//Example Method
public string GetRunningTime(Process p){
string returnString = "00:00:00:00.00";
if(p.HasAcessToStartTime){//Trying to immitate
returnString = DateTime.Now.Subtract(p.StartTime).ToString(@"dd\.hh\:mm\:ss\.ff");
}
return returnString;
}