![]() |
Re: Programm-Optionen
Wenn dir das alles noch zu unsicher ist, was du nochmal erklären könntest,
dann kannst du deine Datei ja im Nachhinein noch verschlüsseln, siehe hier: ![]() ![]() P.S.: Weil du dir solche Gedanken um mögliche Änderungen machst, was passiert, wenn deine INI gelöscht wird? Ich denke auch dafür muß es eine Lösung geben, die eben genau auf Default-Werte hinausläuft. Czapie. |
Re: Programm-Optionen
Also ich würde die Sachen in der Registry speichern
Delphi-Quellcode:
Zum schreiben
uses
Registry;
Delphi-Quellcode:
Zum lesen
with TRegistry.Create do
begin RootKey:=HKEY_LOCAL_MACHINE; OpenKey('SOFTWARE\'+ProgrammName,true); WriteBool('TRAY',Checkbox1.Checked); end;
Delphi-Quellcode:
with TRegistry.Create do
begin RootKey:=HKEY_LOCAL_MACHINE; OpenKey('SOFTWARE\'+ProgrammName,true); if ValueExists('TRAY')then if ReadBool('TRAY')then begin Checkbox1.Checked:=true; end; end; |
Re: Programm-Optionen
@ SleepyMaster: Und was soll das für einen Vorteil gegenüber Ini's haben? Ini's mögen zwar in manchen Augen veraltet sein, doch es gibt ja wohl nichts schlimmeres als Registryeinträge die beim Löschen vergessen wurden und alles zu müllen. Dann lieber ne Ini im Programmverzeichnis.
|
Re: Programm-Optionen
Zitat:
verwende ich grundsätzlich Ini's. Niemals die Registry Ausnahme: Einstellungen die anwendungsübergreifend verwendet werden. |
Re: Programm-Optionen
Hallo,
dem Objekt TInifile fehlen leider die Methoden ReadFont und WriteFont. Das lässt sich Dank OOP aber leicht ändern.
Delphi-Quellcode:
Diese unit verwende ich schon seit D1
unit Inifile2;
interface uses IniFiles, Graphics, Classes, StdCtrls; Type TIniFileExt = Class(TIniFile) procedure WriteFont(Const Section, Ident: String; Value: TFont); function ReadFont(Const Section, Ident: String; default: TFont): TFont; end; implementation uses SysUtils, Consts; procedure TIniFileExt.WriteFont(Const Section, Ident: String; Value: TFont); var Str :String; v :char; Begin V:=' '; Str := ''; Str := Value.Name + ','; Str := Str + ColorToString(Value.Color) + ','; Str := Str + IntToStr(Value.Size) + ','; Case Value.Pitch of fpdefault : v :='d'; fpvariable : v :='v'; fpfixed : v :='f'; end; Str:= Str + v + ','; if fsBold in Value.Style then Str:=Str + 'b'; if fsItalic in Value.Style then Str:=Str + 'i'; if fsUnderline in Value.Style then Str:=Str + 'u'; if fsStrikeOut in Value.Style then Str:=Str +'s'; WriteString(Section,Ident,Str); end; function TIniFileExt.ReadFont(Const Section, Ident: String; default: TFont): TFont; var FFont : TFont; Str,sc : String; I : byte; Begin Str := ReadString(Section,Ident,''); ReadFont := default; I := Pos(',',Str); if i = 0 then exit; FFont := TFont.Create; FFont.Name := Copy(Str,1,i-1); Delete(Str,1,i); i:=Pos(',',Str); if i = 0 then exit; try FFont.Color:= StringtoColor(Copy(Str,1,(i-1))); except FFont.Free; exit; end; Delete(Str,1,i); i:=Pos(',',Str); if i = 0 then exit; try FFont.Size:= StrToInt(Copy(Str,1,(i-1))); except FFont.Free; exit; end; Delete(Str,1,i); i:=Pos(',',Str); if i = 0 then begin FFont.Free; exit; end; sc:=Copy(Str,1,(i-1)); if sc = 'd' then FFont.pitch := fpdefault; if sc = 'v' then FFont.pitch := fpvariable; if sc = 'f' then FFont.pitch := fpfixed; Delete(Str,1,i); FFont.Style:=[]; While byte(Length(Str)) > 0 do Begin Case Str[1] of 'b': FFont.Style := FFont.Style + [fsbold]; 'i': FFont.Style := FFont.Style + [fsitalic]; 'u': FFont.Style := FFont.Style + [fsUnderline]; 's': FFont.Style := FFont.Style + [fsStrikeout]; end; Delete(Str,1,1); end; ReadFont.Assign(FFont); FFont.Free; end; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:15 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