#include "stdafx.h"
#include "ConsoleApplication1.h"
#include <windows.h>
#include <iostream>
#include <string>
#include "afxstr.h"
using namespace std;
CString GetProgramDir()
{
TCHAR exeFullPath[MAX_PATH];
GetModuleFileName(NULL, exeFullPath, MAX_PATH);
CString str = exeFullPath;
return str;
}
int main()
{
CString str = GetProgramDir();
int a = str.ReverseFind('\\');
str=str.Left(a);
string s(str.GetBuffer());
cout << s << endl;
return 0;
}//把字符集从unicode改成多字节//建立consoleMFC工程要不调用不了CString
c++ 取运行目录
最新推荐文章于 2024-07-15 15:38:25 发布