I just tried your code and it initially failed because my path to the
.ini
file was not correct. Once I fixed that it worked fine. You can check for yourself by modifying your code as follows:
int num = GetPrivateProfileString(Section, Key, NULL, buffer, bufferSize, Paths_ini);
if (num == 0)
{
DWORD dw = GetLastError();
std::cout << "Error: " << dw << std::endl;
}
If the error number is 2, then your path to the
.ini
file is not correct. See
GetPrivateProfileString function (winbase.h) - Win32 apps | Microsoft Learn[
^] for full details.