Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi INI File wird nicht erzeugt (https://www.delphipraxis.net/84623-ini-file-wird-nicht-erzeugt.html)

IngoD7 19. Jan 2007 18:50

Re: INI File wird nicht erzeugt
 
Zitat:

Zitat von Hansa
Zitat:

Zitat von IngoD7
Wozu braucht er eine Quelle? ... "Nein, ein Free reicht nicht." Und das stimmt

Weil es eben nicht stimmt. :zwinker:

Delphi-Quellcode:
Im folgenden Beispiel werden die Konfigurationsinformationen mit dem Ereignis OnCreate eines Formulars aus einer INI-Datei gelesen und in der Ereignisbehandlungsroutine für OnClose zurückgeschrieben.

procedure TForm1.FormCreate(Sender: TObject);
var
  Ini: TIniFile;
begin
  Ini := TIniFile.Create( ChangeFileExt( Application.ExeName, '.INI' ) );
  try
    Top    := Ini.ReadInteger( 'Form', 'Top', 100 );
    Left   := Ini.ReadInteger( 'Form', 'Left', 100 );
    Caption := Ini.ReadString( 'Form', 'Caption', 'New Form' );
    if Ini.ReadBool( 'Form', 'InitMax', false ) then
      WindowState = wsMaximized
    else
      WindowState = wsNormal;
  finally
    TIniFile.Free;
    end;
  end;
Quelle : OH. :mrgreen:

Wo ist jetzt da was außer free zu sehen ? :shock:

Du willst uns jetzt provozieren, oder? :roll:

Das, was dafür ausschlaggebend ist, dass das Ding zurückgeschrieben wird, steht - wie du selber aus der Hilfe zitiert hast - im OnClose. Es sind die ganzen Ini.Write...-Befehle.

Zitat:

Zitat von Aus der Online-Hilfe
Delphi-Quellcode:
procedure TForm1.FormClose(Sender: TObject; var Action TCloseAction)
var
  **Ini: TIniFile;
begin
  **Ini := TIniFile.Create( ChangeFileExt( Application.ExeName, '.INI' ) );
  try
    ****Ini.WriteInteger( 'Form', 'Top', Top);
    ****Ini.WriteInteger( 'Form', 'Top', Top);
    *Ini.WriteString( 'Form', 'Caption', Caption );

    ****Ini.WriteBool( 'Form', 'InitMax', WindowState = wsMaximized );
  finally
    ****TIniFile.Free;
  *end;
*end;

Und um dich selbst zu zitieren: Probiere das alles doch einfach mal aus.


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:09 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz