Please Help! CommandLineToArgvW()

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need help with CommandLineToArgvW() functio
I want to get arguments from the command line
my project uses MFC
I need example with this function

thank you
Pol
 
Hi Pola,

Thanks for posting in the community.

To get arguments from the command line in MFC APP
You can tried the following code snippet:
int argCount = 0;
LPWSTR* lpArgv = ::CommandLineToArgvW(::GetCommandLineW(), &argCount);

I found a similar sample in this topic:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=Ot1FHSxS
%24GA.262%40cppssbbsa05&rnum=1&prev=/groups%3Fsourceid%3Dnavclient%26ie%3DUT
F-8%26oe%3DUTF-8%26q%3DCommandLineToArgvW%2BMFC

By the way, if you get the number of the argument, such as the argCount
above, you can retrieve the Argvs directly:
__argv[0] //the execute program's fullname
__argv[1] //the first command line argument, if exist
...
__argv // the ith command line argument, if exist


Wish it helps!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
smart!
By the way, if you get the number of the argument, such as the argCount
above, you can retrieve the Argvs directly...
It's easier to get the number of the arguments simply by using __argc.

regards, Teis



Gary Chang said:
Hi Pola,

Thanks for posting in the community.

To get arguments from the command line in MFC APP
You can tried the following code snippet:
int argCount = 0;
LPWSTR* lpArgv = ::CommandLineToArgvW(::GetCommandLineW(), &argCount);

I found a similar sample in this topic:
http://groups.google.com/groups?hl=...&rnum=1&prev=/groups?sourceid=navclient&ie=UT
F-8%26oe%3DUTF-8%26q%3DCommandLineToArgvW%2BMFC

By the way, if you get the number of the argument, such as the argCount
above, you can retrieve the Argvs directly:
__argv[0] //the execute program's fullname
__argv[1] //the first command line argument, if exist
..
__argv // the ith command line argument, if exist


Wish it helps!

Best regards,

Gary Chang
Microsoft Online Partner Support
 
Back
Top