代码改变世界

[VC++]配置文件读取

2012-01-12 13:43  三犬风  阅读(459)  评论(0编辑  收藏  举报

1.读取VALUE为字符串

DWORD dwRet = 0;

GetCurrentDirectory(MAX_PATH,currentPath);
wsprintf(currentPath,_T("%s%s"),currentPath,iniFile);
dwRet = GetPrivateProfileString(_T("SECTION"),_T("KEY"),NULL,strIP,LenIPBuffer,currentPath);
if (0 == dwRet)
{
    return READ_INI_FAILED;
}

2.读取VALUE为整形

VALUE = GetPrivateProfileInt(_T("SECTION"),_T("KEY"),NULL,currentPath);
if (0 == VALUE )
{
    return READ_INI_FAILED;
}