08-07
10
VC 获取当前应用程序路径
作者:凌晨 日期:2008-07-10
------------------------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);
评论: 0 | 引用: 0 | 查看次数: -
发表评论
上一篇
下一篇

文章来自:
Tags: 