4

I have tried in two ways to get the proocess description

Solution1:-

code:- Process proc = Process.GetProcessById(pid); string process_description= proc.MainModule.FileVersionInfo.FileDescription

Problem:-when we trying to access the MainModule property for some processes 0(idle), 4(system) or services(Having admin acces rights) (most likely those running under SYSTEM credentials) on which user don't have the permission leads to win32 ACCESS DENIED EXCEPTION.

Solution 2:-

 code :
 string process_description=FileVersionInfo.GetVersionInfo(modulePath).FileDescription;

Problem :-Unable to get process decription if file description is not mention in the properties details window of exe file or process which have admin rights .

For example:if process is google chrome. ImageName:-chrome.exe Description :Google chrome I want to get the description part not the Image Name.

Can any one share your ideas how to get process description in taskmanager for particular process id.

Padma Yeddula
  • 167
  • 2
  • 14
  • Your solution 1 appears to be what you need to do. – David Heffernan Jul 10 '14 at 08:53
  • @DavidHeffernan:-Yes,but i have problem with that.when i tried to get the file description for the process which have adim rights it throws a win32 access denied exception.So in this case how can i get the process descrption? – Padma Yeddula Jul 10 '14 at 09:01
  • Why don't you get admin rights? If you cannot do that, find the full path to the executable, and read the version info resource to find the information. – David Heffernan Jul 10 '14 at 09:01
  • @DavidHeffernan:-My requirment is to capture the active window details for all the users like application title,process description ,start time and end time.So all users dont have admin rights. yes i am able to get the full path of the executable but for some executable files filedescription part is empty.so its returning empty which should not. so i thought that i should get the description from task manager – Padma Yeddula Jul 10 '14 at 09:05

1 Answers1

2

The information is contained in the VERSIONINFO resource for the executable file. You are looking for the value named FileDescription.

Use LoadLibraryEx passing LOAD_LIBRARY_AS_IMAGE_RESOURCE. And then use the resource API, FindResource, LoadResource, LockResource etc. to obtain the version info resource. Finally, parse out the information.

Alternatively you could parse the PE file directly which is what I suspect that programs like task manager do for performance reasons. But that would be much more complicated.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490