Visual C++获取程序当前路径
CString CPropertySampleApp::GetCurrWorkingDir()
{
CString strPath;
TCHAR szFull[_MAX_PATH];
TCHAR szDrive[_MAX_DRIVE];
TCHAR szDir[_MAX_DIR];
::GetModuleFileName(NULL, szFull, sizeof(szFull)/sizeof(TCHAR));
_tsplitpath(szFull, szDrive, szDir, NULL, NULL);
_tcscpy(szFull, szDrive);
_tcscat(szFull, szDir);
strPath = CString(szFull);
return strPath;
}
CString strPath;
GetModuleFileName(NULL,strPath.GetBufferSetLength(MAX_PATH+1),MAX_PATH);
strPath.ReleaseBuffer();
int pos = strPath.ReverseFind('\\');
strPath = strPath.Left(pos+1);

浙公网安备 33010602011771号