GetPrivateProfileInt return false or true c++
...
Last edited on
You need to pass the full path as filename parameter.
I know. I've already tried that.
Try this one:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
int main()
{
UINT value = 265;
const char filename[] = "C:\\Temp\\Test.ini";
ofstream dest(filename);
if (!dest)
{
perror("Error creating file: ");
return -1;
}
dest << "[Settings]" << "\n";
dest << "Key=" << value;
dest.close();
UINT actual = GetPrivateProfileIntA("Settings", "Key", 0, filename);
if (actual != value)
{
cout << "Win error: " << GetLastError() << "\n\n";
}
else
{
cout << "Key = " << actual << "\n\n";
}
system("pause");
return 0;
}
|
Either change the filename on line 10 or create a folder C:\\Temp
Topic archived. No new replies allowed.