Home > Software engineering >  How to get command line args from a pid?
How to get command line args from a pid?

Time:03-11

I've an application which contains pid of another process running on the system. I would want to get the command line args with which the other process was launched using Win32 API. I have gone through all process related functions and PSAPI functions too but couldn't find one.

Your help is greatly appreciated!

Thanks,

Kannan

CodePudding user response:

How do I get the command line of another process?

Win32 doesn’t expose a process’s command line to other processes.

...

If you look around in WMI, you’ll find a Win32_Process object, and lo and behold, it has a CommandLine property.

Task manager just uses an undocumented set of APIs in NTDLL instead of using the supported ToolHelp API and PSAPI functions. Process Hacker probably does the same and it is open source so you could look at that.

  • Related