it's impossible to get app info(name, maybe other) by Process
class? I know i can get .exe file name, but i want get app name. It is desirable that the solution be cross-platform?
I can get MainWindowTitle 'Новая вкладка - Google Chrome', but i need application name like in task manager (Google Chrome). I can parse title, but this is not a universal way.
CodePudding user response:
To get the descrition of the executable file for a running process, you can use
string GetProcessDescription(Process process)
{
try
{
return process.MainModule?.FileVersionInfo?.FileDescription;
}
catch
{
return null;
}
}
The exception handler is necessary because you might not have the permission to access the information, or the process might not have a file module at all.