#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
int num = ::GetPrivateProfileInt(L"Images", L"level_0", 9, L"C:\\Users\\liuzhichao\\source\\repos\\ConsoleApplication2\\Debug\\config.ini");
wchar_t buf[128];
::GetPrivateProfileStringW(L"Images", L"level_1", L"0", buf, 128, L"C:\\Users\\liuzhichao\\source\\repos\\ConsoleApplication2\\Debug\\config.ini");
std::wstring str = std::wstring(buf);
cout << num << endl;
int num2 = _wtoi(buf);
std::wcout << str << std::endl;
std::wstring strnum = L"168";
WritePrivateProfileStringW(L"Images", L"level_1", strnum.c_str(), L"C:\\Users\\liuzhichao\\source\\repos\\ConsoleApplication2\\Debug\\config.ini");
memset(buf, 0, 128);
GetPrivateProfileSectionW(L"Images", buf, 128, L"C:\\Users\\liuzhichao\\source\\repos\\ConsoleApplication2\\Debug\\config.ini");
str = buf;
return 0;
}
WritePrivateProfileString如果文件不存在,则可以自动创建文件。但是如果文件夹不存在,则需要首先创建文件夹。