I am using the below code for getting process information from my 32 bit application.
var process = Process.GetProcessById((int)processID);
if (process != null && process.MainModule != null && process.MainModule.FileVersionInfo != null)
{
windowInfo.CompanyName = process.MainModule.FileVersionInfo.CompanyName;
windowInfo.FileDescription = process.MainModule.FileVersionInfo.FileDescription;
windowInfo.FileName = process.MainModule.FileVersionInfo.FileName;
windowInfo.FileVersion = process.MainModule.FileVersionInfo.FileVersion;
windowInfo.ProductName = process.MainModule.FileVersionInfo.ProductName;
windowInfo.ProductVersion = process.MainModule.FileVersionInfo.ProductVersion;
}
It throws Win32Exception
when I query the same for a 64 bit process. I tried the same in an independent application following the solution given in this post and it worked when I changed my application to be a 64 bit. I can not do the same in my main application.
Does anyone have a workaround? I just want to query the parameters inside the "if" body.
Let me know if any more further information is required.