zoukankan      html  css  js  c++  java
  • 调用外部exe传递参数 接受参数

    最近开发一个Activex控件,需要调用外部exe(接受多个参数),并且传递多个参数。

    这里主要介绍调用外部exe传递参数和exe接受参数。

    调用外部exe的几种方法具体用法请参考:

    http://blog.163.com/laowu_000/blog/static/47198890201042021747662/

    http://blog.csdn.net/moyumoyu/article/details/6767621

    我用到的是WinExec()函数。

    1.如果仅仅是调用外部exe文件打开一个文件,调用方法:WinExec("调用的.exe  要打开的.txt",1),中间用空格隔开,外部exe中不需要写接受函数。

    2.调用外部exe并传递多个参数

      调用方法:WinExec("调用的.exe 参数1 参数2 参数3",1),多个参数中间用空格或其他分隔符隔开。

        exe接受参数:

    CString szCmd = AfxGetApp()->m_lpCmdLine; //szCmd 接收到的字符串是 :参数1 参数2 参数3
    
    CStringArray str;
    
    int nSize = splitString(szCmd, ' ', str );//分割字符串
    
    for(int i=0;i<nSize ;i++){
       str.GetAt(i);//各个参数
    }
    
    int splitString(CString str, char split, CStringArray& strArray)
    {
        strArray.RemoveAll();
    
        CString strTemp = str;    //此赋值不能少
        int nIndex = 0; //
        while( 1 )
        {
            nIndex = strTemp.Find(split);
            if( nIndex >= 0 )
            {
                strArray.Add( strTemp.Left( nIndex ) );
                strTemp = strTemp.Right( strTemp.GetLength() - nIndex - 1 );
            }
            else break;
        }
        strArray.Add( strTemp );
           return strArray.GetSize();
    }                       
  • 相关阅读:
    MongoDB ObjectId
    MongoDB固定集合
    MongoDB 正则表达式
    MongoDB Map Reduce
    MongoDB操作
    VIM跳到指定行
    linux之echo命令
    rpm and yum commands
    CentOS 7 下的软件安装建议
    apt系统中sources.list文件的解析
  • 原文地址:https://www.cnblogs.com/xsgame/p/3070575.html
Copyright © 2011-2022 走看看