string GetExePath(void)
{
char szFilePath[MAX_PATH + 1]={0};
GetModuleFileNameA(NULL, szFilePath, MAX_PATH);
(strrchr(szFilePath, ‘\\‘)+1)[0] = 0; // 删除文件名,只获得路径字串
string path = szFilePath;
return path;
}
这个获取的是exe所在的目录,一般为debug里或者release里 。string a;
a.assign(buf);
cout<<a<<endl;
a.append("\\..\\"); //设置为当前工作路径为当时的上一级
cout<<a<<endl;
//a=a+"..\\";
SetCurrentDirectory(a.c_str()); //设置
SetCurrentDirectory("E:\\KanKan");
GetCurrentDirectory(1000,buf);
//这样你就可以直接进入到e:\\KanKan目录下
import os,sys print os.path[0]
VC++ / python 如何获取工程当前路径及对应的其相关路径,布布扣,bubuko.com
VC++ / python 如何获取工程当前路径及对应的其相关路径
原文:http://blog.csdn.net/mjhmjhmjh123/article/details/23703333