Alternatives to NtQueryInformationProcess to get commandline

1.9k views Asked by At

Hello I am using NtQueryInformationProcess() to retrieve the command line of current process (via the RTL_USER_PROCESS_PARAMETERS in the PEB returned by NtQueryInformationProcess()) on Windows 7.

But the problem is this The NtQueryInformationProcess function and the structures that it returns are internal to the operating system and subject to change from one release of Windows to another

So Please suggest some alternatives for the same to maintain the compatibility of application

1

There are 1 answers

1
Anders On BEST ANSWER

For current process it is easy (in user mode), just use GetCommandLine. For a different process, you have to go outside the Win32 API:

WMI: Win32_Process.CommandLine

See also: The Old New Thing