Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Inhalt vom Type Cardinal in eine Datei speichern ? (https://www.delphipraxis.net/45388-inhalt-vom-type-cardinal-eine-datei-speichern.html)

smart 5. Mai 2005 10:31


Inhalt vom Type Cardinal in eine Datei speichern ?
 
Ich möchte den Inhalt vom Type Cardinal in eine Datei speichern. Wie geht man da vor? Eine Umwandlung als String oder Integer geht nicht .

Dax 5. Mai 2005 10:35

Re: Inhalt vom Type Cardinal in eine Datei speichern ?
 
Eine Möglichkeit wäre
Delphi-Quellcode:
var MyFile: file of Cardinal;
Diesen File-Typ sprichst du an wie den normalen File-Typ auch. Noch besser wäre allerdings Delphi-Referenz durchsuchenTFileStream, den du z.B. so handhaben kannst:
Delphi-Quellcode:
var F: TFileStream;

F := TFileStream.Create(MyFileName, fmOpenReadWrite);

// speichern
F.Position := 0;
F.Write(MyCardinal, sizeof(Cardinal));

// lesen
F.Position := 0;
F.Read(MyCardinal, sizeof(Cardinal));

// am Ende freigeben nicht vergessen!
F.Destroy;

smart 5. Mai 2005 10:46

Re: Inhalt vom Type Cardinal in eine Datei speichern ?
 
Vielen Dank für Deine schnelle und umfassende Antwort.


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:22 Uhr.

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