08-07
10

VC 获取当前应用程序路径

------------------------1------------------------- 

CString strCommandLine = ::GetCommandLine();
  int i;
 int nLen = strCommandLine.GetLength();
 for(i = nLen - 1; i >= 0; i--)      //从最后一位开始寻找'\\'获得索引i
 {
  CHAR a = strCommandLine.GetAt(i);
  if(a == '\\')
  {
   break;
  }
 }

 strCommandLine.ReleaseBuffer(i + 1);//释放剩余空间
 strCommandLine.Delete(0, 1);

 MessageBox(strCommandLine);

--------------------------2----------------------------

 CString strCommandLine = ::GetCommandLine();
 int i;

 i=strCommandLine.ReverseFind('\\');//寻找最后一个符合要求的索引
 strCommandLine.ReleaseBuffer(i + 1);//释放剩余空间
 strCommandLine.Delete(0, 1);

 MessageBox(strCommandLine);




文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: 获取路径
相关日志:

评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.