PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, September 10, 2022

[FIXED] How can I get application by process

 September 10, 2022     c#, cross-platform, process     No comments   

Issue

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?

Example: enter image description here

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.


Solution

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.



Answered By - Klaus Gütter
Answer Checked By - Timothy Miller (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing