Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Marty15

? on ini files

This topic is 5840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you use .INI files in c++? I tried this but it did''nt work, can someone help me please, TIniFile *pIniFile = new TIniFile("c:\MyApp\bin\MyApp.ini");

Share this post


Link to post
Share on other sites
Advertisement
An error message would help. Also specify what compiler you''re using. TIniFile sounds like a Borland specific thing.

Share this post


Link to post
Share on other sites
Don''t forget the double-backslashes...
TIniFile *pIniFile = new TIniFile("c:\\MyApp\\bin\\MyApp.ini"); 

Share this post


Link to post
Share on other sites
I''m using Borland C++ Builder 4 but i started the project using the console wizard and some of the things like TIniFile dont work.

By the way the error message is.

Declaration Syntax Error.

Thanks

Share this post


Link to post
Share on other sites
My guess is you are using Borland c++ builder.. so am I sometimes...

remember to include inifiles.hpp like this:

#include <inifiles.hpp>

somewhere in the code before using the TIniFile object..
here is an example of using the object (this is really simple, I like that object :-)


  
// this is how you read

TIniFile *ini;
ini = new TIniFile(
ChangeFileExt( Application->ExeName, ".INI" ) );
Top = ini->ReadInteger( "Form", "Top", 100 );
Left = ini->ReadInteger( "Form", "Left", 100 );
Caption = ini->ReadString( "Form", "Caption",
"Default Caption" );
ini->ReadBool( "Form", "InitMax", false ) ?
WindowState = wsMaximized :
WindowState = wsNormal;
delete ini;


// and how you write

TIniFile *ini;
ini = new TIniFile(ChangeFileExt( Application->Name, ".INI" ) );
ini->WriteInteger( "Form", "Top", Top );
ini->WriteInteger( "Form", "Left", Left );
ini->WriteString ( "Form", "Caption", Caption );
ini->WriteBool ( "Form", "InitMax",
WindowState == wsMaximized );
delete ini;


this was copied straight from the help file.. search on TIniFile.. there is a paragraph called "Using TIniFile"..
Remember to use your products documentation before asking for further help :-)

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!