C++iniファイル読み書き

#include <iostream>
#include <Windows.h>
int main() {
    // INIファイルのパスとセクション、キーを指定
    LPCWSTR iniFilePath = L"C:\\Users\\sannp\\Desktop\\SAMC1\\INI\\COM.ini";
    LPCWSTR section = L"FTE";
    // キーを指定
    //LPCWSTR key1 = L"section1";
    //LPCWSTR key2 = L"section2";
    //LPCWSTR key3 = L"section3";
    LPCWSTR keys[3] = { L"section1", L"section2",  L"section3" };
    //// 書き込む文字列
    //LPCWSTR writeString = L"Hello, World!";
    //// 書き込む文字列のサイズ(バイト単位)
    //DWORD writeSize = static_cast<DWORD>*1;
    //// INIファイルへの書き込み
    //for (int i = 0; i < 3; ++i) {
    //    BOOL writeResult = WritePrivateProfileString(section, key[i], writeString, iniFilePath);
    //    if (writeResult == FALSE) {
    //        std::cerr << "Failed to write to INI file." << std::endl;
    //        return 1;
    //    }
    //}
    // 読み込み用のバッファ
    //wchar_t buf1[256];
    //wchar_t buf2[256];
    //wchar_t buf3[256];
    wchar_t buf[256];
    for (int i = 0; i < 3; ++i) {
        // INIファイルからデータを取得
        DWORD bytesRead = GetPrivateProfileString(section, keys[i], NULL, buf, sizeof(buf) / sizeof(wchar_t), iniFilePath);
        // 取得したデータを表示
        if (bytesRead > 0) {
            std::wcout << "Data read from " << keys[i] << ": " << buf << std::endl;
        }
    }
    //// INIファイルからデータを取得
    //DWORD bytesRead1 = GetPrivateProfileString(section, key1, NULL, buf1, sizeof(buf1) / sizeof(wchar_t), iniFilePath);
    //DWORD bytesRead2 = GetPrivateProfileString(section, key2, NULL, buf2, sizeof(buf2) / sizeof(wchar_t), iniFilePath);
    //DWORD bytesRead3 = GetPrivateProfileString(section, key3, NULL, buf3, sizeof(buf3) / sizeof(wchar_t), iniFilePath);
    //// 取得したデータを表示
    //if (bytesRead1 > 0) {
    //    std::wcout << "Data read from " << key1 << ": " << buf1 << std::endl;
    //}
    //if (bytesRead2 > 0) {
    //    std::wcout << "Data read from " << key2 << ": " << buf2 << std::endl;
    //}
    //if (bytesRead3 > 0) {
    //    std::wcout << "Data read from " << key3 << ": " << buf3 << std::endl;
    //}
    return 0;
}

*1:wcslen(writeString) + 1) * sizeof(wchar_t