namespace po = boost::program_options;  po::options_description desc("Allowed options");
  desc.add_options()
("help", "produce help message")
("letter", po::wvalue<std::wstring>(), "set disk letter")
("ip",po::value<std::string>(),"set briefcase server ip address")
;  po::variables_map vm;
  po::store(po::parse_command_line(argc, argv, desc), vm);  po::notify(vm);  if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
  }  std::wstring mount_point = L"G:";
  std::string bc_server_ip = "";  if(vm.count("letter")) mount_point = vm["letter"].as<std::wstring>();
  if(vm.count("ip") ) bc_server_ip = vm["ip"].as<std::string>();
用红色标注的如何该成windows 应用程序呀,在控制台上还有argc,argv,但是在应用程序中没有呀,怎么办呀。

解决方案 »

  1.   

    mfc 程序也有 argc argv的
      

  2.   

    那个地方是boost解析 argv的地方吧,就是命令行参数,就几个字符串而已,自己写。
      

  3.   

    因为用了winmain 里面没有argc,argv,而原来的程序是控制台程序用的是_tmain所以是有argc,argv的,如何将其改成winmain
      

  4.   

    BOOL CExeApp::InitInstance() 

        int n = __argc; 
    for(int i = 1 ; i < n ; i++)
    {
    AfxMessageBox(__targv[i]);
    }
    }
      

  5.   

    ANSI console processes written in C can use the argc and argv arguments of the main function to access the command-line arguments. ANSI GUI applications can use the lpCmdLine parameter of the WinMain function to access the command-line string, excluding the program name. The main and WinMain functions cannot return Unicode strings.
    Unicode console process written in C can use the wmain or _tmain function to access the command-line arguments. Unicode GUI applications must use the GetCommandLineW function to access Unicode strings.
      

  6.   


    LPWSTR *CommandLineToArgvW(          LPCWSTR lpCmdLine,
        int *pNumArgs
    );
    自己处理一下呗
      

  7.   

    自己取命令行啊.
    #include <windows.h>
      #include <stdio.h>
      #include <shellapi.h>
      int __cdecl main()
      {
      LPWSTR *szArglist;
      int nArgs;
      int i;
      szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
      if( NULL == szArglist )
      {
      wprintf(L"CommandLineToArgvW failed\n");
      return 0;
      }
      else
      {
      for( i=0; i<nArgs; i++)
      printf("%d: %ws\n", i, szArglist[i]);
      LocalFree(szArglist);// Free memory allocated for CommandLineToArgvW arguments.
      return(1);
      }
      }
      

  8.   

    大概就是这个了
    int argc ;
    wchar_t ** argv = CommandLineToArgvW( GetCommandLine() , &argc 
    );
    只不过你得自己处理一下宽字符到 ansi 的转换。
      

  9.   

    GetCommandLine(); CommandLineToArgvW();
      

  10.   


    po::store(po::parse_command_line(argc, argv, desc), vm);这行怎么改,我按照14楼说的做了,老上重启电脑了