GetPrivateProfileString讀取INI配置文件信息

CString CConfigPro::GetConfigValue(CString strAppName, CString strKeyName)

{

TCHAR szValue[MAX_PATH];

CString strCurrentPath, strConfigPath, strValue;

GetModuleFileName(NULL, strCurrentPath.GetBufferSetLength(MAX_PATH+1), MAX_PATH);

strCurrentPath.ReleaseBuffer();

int nPosIndex = strCurrentPath.ReverseFind('//');

strConfigPath = strCurrentPath.Left(nPosIndex) + _T("//Config.ini");

GetPrivateProfileString(strAppName, strKeyName, _T(""), szValue, MAX_PATH, strConfigPath);

strValue = szValue;

return strValue;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章