GetPrivateProfileInt - generation of ini file

Started by
2 comments, last by Tispe 11 years, 7 months ago
Hi

I wish to use a .ini file to store values such as resolution, windowed mode etc. Does the GetPrivateProfileInt generate an ini file if it does not exist, or do I need to do that with CreateFile myself?

Also, if GetPrivateProfileInt does not find the key it is looking for, it takes the default. But does it update the ini file with the new default key?


I want my application to be able to generate a new ini file if it is missing, populating it with sections and keys with defaulted values at start up.
Advertisement
Do you really need a .ini file? From the doc:

Note This function is provided only for compatibility with 16-bit Windows-based applications. Applications should store initialization information in the registry.
Hi Tispe!

I recommend that you write your own config file. Step on the. ini -extension to conveniently associate the file type with notepad on windows, or use a different extension.

Create a simple parser, and don't delve into how anyone thinks you should be doing it. Chances are they'll deprecate it soon anyway.

You can learn much from parsing, - and using files on relative paths rather than utilizing the windows registry means portability for your application.

Sorry for not actually answering your question. ;)
I always hate these windows functions that take wide chars. I get all kinds of compiler errors relating to LPCWSTR. I need to add 5 lines of code for each function call just to do conversion.......

Why aren't there a "WritePrivateProfileInt"???

This topic is closed to new replies.

Advertisement