当前位置:   article > 正文

GetCommandLine()与AfxGetApp()->m_lpCmdLine的区别

afxgetapp()->m_lpcmdline

在一个主进程中,调用别的子进程时有两种方法:

1)使用CreateProcess

2)使用ShellExecute

上面这两种方法均可调用别的进程的.exe,在调用.exe的同时还可以给该子进程传递参数。

其中,子进程中获取命令参数的方法大致有以下三种:

1)::GetCommandLine() 

使用方法:

CString str = ::GetCommandLine()

2)    AfxGetApp()->m_lpCmdLine

     CWinApp *thisApp = AfxGetApp();
    CString strCmdLine = thisApp->m_lpCmdLine;

3)for (int i=0;i<__argc;i++)
{
__argv[i];

}

依次获取

其中:GetCommandLine()与AfxGetApp()->m_lpCmdLine是有区别的

AfxGetApp()->m_lpCmdLine只可以获取到ShellExecute传过来的参数。

::GetCommandLine() 则都可以。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/467175
推荐阅读
  

闽ICP备14008679号