Windows .INI files are, as a tradition, placed in the same folder as the executable and use progname.ini as the filename.
Originally Posted by cas
The easiest way to do this is...
The nice part about doing it this way is that it allows the user to have multiple copies of the program (by renaming) with different settings...
TCHAR SetFile[MAX_PATH + sizeof(TCHAR) ]; // max path length + room for a null.
// get program's name and path
// note: in console mode you can substitute argv
// locate file extension
Ext = strstr(SetFile,".exe");
// change to INI
// load settings file
sf = fopen(SetFile,"r");
// process settings in here.
// save settings
sf = fopen(SetFile,"w");
// process settings out here.
For example: if you have MyProgram.exe it produces MyProgram.ini but if you copy and rename the program to MyFancy.exe it will produce MyFancy.ini automatically.