*.INI files or what??
can i use the ini file format to store the object properties in my 3d real time strategy game??
thnx
The standard .ini format is just an ascii file format (the same thing as .txt) with a few scripting rules which basically involves having a keyword, and equal sign, and the desired value on the same line, with logical groupings denoted by keywords surrounded by square brackets (I use this all the time). It''s nothing special. The only reason it''s used a lot is the fact that MFC contains special file reading functions to interpret that particular scripting format (functions which, by the way, will also retrieve from the registry depending on your initial settings for where and what the .ini is). So, sure you can use the format as long as the information you''re storing can be stored as text values... but unless you want to use MFC you''ll have to write your own script interpreter for it, though the file is so simple it wouldn''t be hard... or you can stick the .ini extension on a file with your own internal setup, which might be better because if you''re doing object properties you might want to do some encryption while you''re at it (just a suggestion) and/or you might want to use binary.
-fel
-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
You don''t need to use MFC in order to use library functions to access ini files. GetPrivateProfileString(), WritePrivateProfileString(), GetPrivateProfileInt(), etc., etc. are part of the Windows API and can be accessed without using MFC. Binary information can be written with WritePrivateProfileStruct() and read with GetPrivateProfileStruct().
This is of course, all deprecated. Win32 programs should not use ini files, but instead use the registry.
This is of course, all deprecated. Win32 programs should not use ini files, but instead use the registry.
Is it bad programming practice to use these legacy functions?
I know quite well that Microsoft does not want us to use these functions, but INI files are more convienient for games in many cases. For instance, you may go over to someone elses house and you want to load preferences from your system, all you do is stick your game INI''s on a disk and bring it. Much easier than exporting registry settings if you ask me. (Perhaps a bad example, but it shows the point)
-Dan
I know quite well that Microsoft does not want us to use these functions, but INI files are more convienient for games in many cases. For instance, you may go over to someone elses house and you want to load preferences from your system, all you do is stick your game INI''s on a disk and bring it. Much easier than exporting registry settings if you ask me. (Perhaps a bad example, but it shows the point)
-Dan
D. Smith
Define bad programming practice.... I don''t think it''s anywhere near as bad as doing a division without handling the divide by zero case or writing a potentially unlimited set of data into a finite buffer.
However, the ini file API is extremely deprecated, and on NT kernels, they don''t even write to/read from actual ini files. They access pseudo-ini files in the registry. Quite possibly these functions will be dropped completely from the API in future API releases. So if you want your application to be as future proof as possible, don''t use them.
However, the ini file API is extremely deprecated, and on NT kernels, they don''t even write to/read from actual ini files. They access pseudo-ini files in the registry. Quite possibly these functions will be dropped completely from the API in future API releases. So if you want your application to be as future proof as possible, don''t use them.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement