2

How to get this part of process name with C#?

Task manager process names

WindowsAPI.GetWindowThreadProcessId(hwnd, out pid);
Process p = Process.GetProcessById((int)pid);
p.MainWindowTitle.ToString();

is closes I've got to. But for many programs it shows opened window names. For example instead of "Google Chrome" it shows name of the active tab.

EDIT: Solution in "possible duplicated" thread lists things I've tried. From what I've gathered "Process" doesn't even contain information which is used in Task manager.

JuztBe
  • 71
  • 1
  • 9
  • `Process.ProcessName` I think https://msdn.microsoft.com/en-us/library/system.diagnostics.process(v=vs.110).aspx – JamesFaix Feb 05 '18 at 13:35
  • 1
    @JamesFaix it's closer. Much closer. Actually usable now, but still not exactly that. It matches for some, but for others not quite. For example taskmanager shows "Microsoft Power Point" but output from .ProcessName is "POWERPNT". I went trough almost everything what's inside a process in debug mode and couldn't find exact line of text which is used in taskmanager. – JuztBe Feb 05 '18 at 19:25
  • 1
    I think what you are looking for can be releted to file discription. Look here https://stackoverflow.com/questions/24672044/how-to-get-the-process-description-based-on-process-idc-net – Stefan W. Feb 06 '18 at 08:04
  • @StefanW. Yes, exactly what I was looking for. Thanks – JuztBe Feb 06 '18 at 10:27

0 Answers0