[VC++]配置文件读取

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;
}

原文地址:https://www.cnblogs.com/sanquanfeng/p/2320509.html