您的位置:首页 > 其它

vc读取当前路径和读取配置ini文件

2014-06-04 16:41 288 查看
//获取路径
std::string GetApplicationDir()
{
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR   wpath[MAX_PATH];

GetModuleFileNameW(hModule, wpath, MAX_PATH);
std::wstring wide(wpath);
std::string path = CefString(wide);
path = path.substr( 0, path.find_last_of("\\/") );
return path;
}


获取配置ini文件

//这里配置网址 2014-06-04
std::string path=GetApplicationDir();
std::string File = std::string("\\httpUrl.ini");

std::string pathFile = path+File;

char strUrl[100];
int i= ::GetPrivateProfileStringA("config","url","",strUrl,100, pathFile.data());
//这里要注意
//pathFile.data()是const char*类型如果定义在外面如下:
//const char* pa=pathFile.data()或const char* pa=pathFile.c_str()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: