-
INI File Poser...
Here's the story...
I'm using a function which implements GetPrivateProfileString to read values from an INI file. Now, this function requires a value for strApplicationname, which is basically the section of the INI File to read the value from. This is marked in the INI File by "[AppName]".
Now my problem is that the INI files I want to read from do not have such a marking, there are just values with no section header.
Does anyone have any idea how I can read values from an INI File without specifying the AppName, or at least how I can insert a null value into a string ("" is no good, this looks for a section called []).
TIA
-
I have never heard of an INI file without the bracket section.
Every INI file has to look similar to this.
[Bracket Section]
Field1="Hello"
Field2="World"
If it does not have the bracket section "[AppName]", why don't you added it in?
-
I can't add any markers to the INI file, as they are used by the Serious Sam TSE Dedicated Server, and it doesn't work if any markers are added to the files...There are various ways I can work around this, but I'd be really grateful if there are any simple solutions.
TIA
-
Can you give us a sample of what the file might look like?
-
This is the contents of init.ini, the initial config file for the dedicated server. I tried adding blank markers to the file, but the DedServ ignored the file contents, rendering that idea useless.
Code:
// this adjusts initial parameters that will be used for this server
net_iPort = 25600; // port to run on - change if you want to run more servers on one computer
gam_iStartMode = 2; // game mode (0=coop, 1=scorematch, 2=fragmatch)
gam_iStartDifficulty = -1; // difficulty (-1=tourist, 0=easy, 1=normal, 2=hard, 3=serious)
gam_ctMaxPlayers = 8; // max number of players accepted
gam_bWaitAllPlayers = 0; // set this to wait for all player to join
gam_iCredits = 0; // number of credits for respawning
gam_bWeaponsStay = 0; // weapons stay on/off
gam_iTimeLimit = 0; // timelimit(minutes) 0=no timelimit
gam_iFragLimit = 20; // fraglimit
gam_strSessionName = "MarMac SSTSE Fragmatch 1";
ded_tmTimeout = 20; // timeout after level is finished
ser_bWaitFirstPlayer = 1; // wait until first player is joined
-
1 Attachment(s)
If are just attempting to READ the values, here is a module I wrote for that purpose a while ago:
You load the INI first using
LoadINI(iniName)
Then to get values:
GetIniValue("General", "NumberOfLevels")
Would Get
[General]
NumberOfLevels = 5
It would return 5
It's relatively intellegent and for any value not in a header (such as your example) it will be in "Uncategorized"
-
Cheers Lord Rat, you're a star :D