About command-line arguments

Source: Internet
Author: User

MFC command-line parameters get

int Nnum= 0;

LPWSTR* LP=COMMANDLINETOARGVW(getcommandlinew(), &nnum);

ASSERT (0);

for (int i = 0; I<nnum; I+ +)

{

AfxMessageBox (Lp[i]);

}


When calling Aa.exe with Aa.bat or entering "aa.exe-999" at the command prompt, the 1th command line parameter received by Aa.exe is the path to EXE, and the 2nd is-999


When you create an EXE in CreateProcess, there is no default 1th parameter, so the command line arguments need to be passed in from the 2nd argument


CreateProcess only the 1th argument to start the specified process, which means CreateProcess ("", "aa.exe-123" ...) is unable to start the process


Either way, the default delimiter is a space, so if you want to pass the path, there is no space in the path, if you can not guarantee, you may add quotation marks at both ends of the argument, such as: Test322.exe "C:\aa bb\cc DD"


When you enter "aa.exe-999" at the command prompt, the operating system will have an encoding conversion process, that is, you do not need to care whether Aa.exe is ANSI or Unicode encoding


This article is from "Bobo software qq:3083279843" blog, please be sure to keep this source http://boyka3721.blog.51cto.com/10568852/1681941

About command-line arguments

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.