Reputation: 103
I found out that the command line arguments for a program run in windows are stored in Process Environment block.I found out more that inside PEB there is a structure called RTL_USER_PROCESS_PARAMETERS , which holds a member variable named UNICODE_STRING CommandLine; can i access this variable by writing a c code ? please assist For more information about PEB refer this link http://msdn.microsoft.com/en-us/library/aa813706%28VS.85%29.aspx
Upvotes: 0
Views: 233
Reputation: 36308
You need the GetCommandLine
function. Even if your program is ANSI, you can still explicitly call the wide version, GetCommandLineW
.
This function is documented on MSDN. Look in the Requirements section and you'll see that it is defined in WinBase.h
but that you should include Windows.h
. It is only available starting with Windows XP, so depending on the version of the SDK that you're using you might need to define _WIN32_WINNT
first:
#define _WIN32_WINNT 0x0502
#include <windows.h>
Upvotes: 2