C++读取配置文件ini

一、设置 ini 保存位置

// 保存到 appdata 中
LPCWSTR GetIniPath()
{
    WCHAR buffer[MAX_PATH];
    BOOL result = SHGetSpecialFolderPath(0, buffer, CSIDL_LOCAL_APPDATA, false);
    wcscat(buffer, L"\GPRIniConfig.ini");
    return buffer;
}

二、写 数据

WritePrivateProfileStringW(_T("config"), _T("rotate"), _T("90"), GetIniPath());

三、读数据

int init_rotate = GetPrivateProfileInt(_T("config"), _T("rotate"), 0, GetIniPath());
原文地址:https://www.cnblogs.com/shiyixirui/p/15324072.html