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());

 

posted @ 2021-09-23 14:33  十一的杂文录  阅读(679)  评论(0编辑  收藏  举报