Windows WTL using command-line arguments

Source: Internet
Author: User

The two methods:

The first type:

1 intWINAPI _tWinMain (hinstance hinstance, hinstance/*hprevinstance*/, LPTSTR Lpstrcmdline,intncmdshow) {2         intARGC =0;3LPWSTR *argv=NULL;4     //splitting command-line arguments5 uses_conversion;6LPCWSTR temp=a2w (lpstrcmdline);7argv= COMMANDLINETOARGVW (temp, &argc);8         //There are two parameters argc argv, unlike the console program: The number of ARGC is the actual number of parameters, not including the. \test.exe itself. ARGV, Argv[0] is the first parameter, not a. \test.exe9     //This method has a flaw, when the command parameter has a space, parsing fails, resulting in incomplete parameters. Ten}

The second type:

1#include <misc/cmdline.h>2 intWINAPI _tWinMain (hinstance hinstance, hinstance/*hprevinstance*/, LPTSTR Lpstrcmdline,intncmdshow) {3 cmdline cmdline;4 CmdLine. Analyze (lpstrcmdline);5 6     if(CmdLine. Hasparam ("Test")){7printf"%s", cmdline["Test"]);8     }9 } Ten //This method in the command line parameter input is key:value form, in the program can use KEY to get value, the class also has SetParam and other methods, please refer to the source code.  OneUse the. \test.exe-key:value

At this point two methods are finished, there are suggested small partners can give me comments.

If you want to reprint, please indicate the source: http://www.cnblogs.com/guozht/7680893.html

Windows WTL using command-line arguments

Related Article

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.