Ejemplos para Programadoras de Delphi:

Dealing with .ini files:

{
  This sample code is presented as is.
  Although every reasonable effort has been
  made to insure the soundness of the example
  below, Idianna Software inc. makes no warranty
  of any kind with regard to this program sample
  either implicitly or explicitly.

  This program example may be freely distributed for the
  use of writing computer programs only. Any other use of
  this material requires written permission from Idianna Software inc.

  (c) 1997 Idianna Software inc. All rights reserved.
 }

{
  This example shows how to use .ini files.
}
Procedure IniIO;
{Author Jon Vote 10/97}

const FILE_NAME = 'test.ini';
      CRLF = chr(13) + chr(10);

var IniFile : TIniFile;

begin
  {Create the .ini file}
  IniFile := TIniFile.Create(FILE_NAME);

  {Write some strings}
  IniFile.WriteString('Strings', 'One', 'This is a string');
  IniFile.WriteString('Strings', 'Two', 'This is another string');

  {Write some integers}
  IniFile.WriteInteger('Numbers', 'Number1', 5);
  IniFile.WriteInteger('Numbers', 'Number2', 5);

  {Write some booleans}
  IniFile.WriteBool('Bools', 'Value1', True);
  IniFile.WriteBool('Bools', 'Value2', False);

  ShowMessage(FILE_NAME + ' in Windows\System has been created
  with test values');

  {Retrieve some of the values - the third parameter is the default}
  ShowMessage ('The second string entry is:' +  CRLF + CRLF +
  '[Strings]' + CRLF +
                    + 'Two=' + IniFile.ReadString('Strings', 'Two', ' '));
  ShowMessage ('The first numeric entry is:' + CRLF + CRLF +
  '[Numbers]' + CRLF +
                    + 'Number1=' + IntToStr(IniFile.ReadInteger('Numbers',
					'Number1', -1)));

  if IniFile.ReadBool('Bools', 'Value1', false) then
     ShowMessage('The first boolean value is True')
  else
     ShowMessage('The first boolean value is False');

  if IniFile.ReadBool('Bools', 'Value2', false) then
     ShowMessage('The second boolean value is True')
  else
     ShowMessage('The second boolean value is False');

end;


 


 
 
 
 
 

Tiene el Poder del
Cafe de Guatemala