vc读取配置

来源:互联网 发布:连云港房地产数据 编辑:程序博客网 时间:2024/06/05 18:26

 CString strIP;
 GetPrivateProfileString(_T("DataBase"), _T("IP"), _T(""), strIP.GetBufferSetLength(MAX_PATH), MAX_PATH, getPath() + "//config.ini");
 strIP.ReleaseBuffer();
 strIP.TrimLeft();
 strIP.TrimRight();

 

 


//------------------------------函数--------------------------------------
static CString getPath()
{
 CString sPath;
 GetModuleFileName(NULL, sPath.GetBufferSetLength(MAX_PATH + 1), MAX_PATH);
 sPath.ReleaseBuffer();
 int nPos;
 nPos = sPath.ReverseFind('//');
 sPath = sPath.Left(nPos);
 return sPath; 
}

原创粉丝点击