您现在的位置是:网站首页 > 语言基础 > C++获取程序名称

简介本文介绍一个C++代码片段:如何在C++中获取程序名称,感兴趣的朋友可以参考一下。

代码片段

// 获取程序名称
CString GetCurAppName()
{
	CString strPath;
	int nPos;
	GetModuleFileName(NULL, strPath.GetBufferSetLength(MAX_PATH + 1), MAX_PATH);
	strPath.ReleaseBuffer();
	nPos = strPath.ReverseFind(_T('\\'));
	int iRight = strPath.GetLength() - nPos - 1;
	strPath = strPath.Right(iRight);
	return strPath;
}



更多为你推荐