AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte KodeZwergs TIniHelper Klasse
Thema durchsuchen
Ansicht
Themen-Optionen

KodeZwergs TIniHelper Klasse

Ein Thema von KodeZwerg · begonnen am 5. Nov 2018 · letzter Beitrag vom 17. Nov 2018
 
Benutzerbild von KodeZwerg
KodeZwerg

Registriert seit: 1. Feb 2018
3.691 Beiträge
 
Delphi 11 Alexandria
 
#1

KodeZwergs TIniHelper Klasse

  Alt 5. Nov 2018, 01:01
Es geht um ein kleines mini Projekt was einem dem Umgang mit Ini Dateien hoffentlich positiv erleichtern soll.
In dieser Fassung ist alles noch wie ein Rohdiamant und auch alles noch von außen erreichbar, was später entfernt wird.

Diese Fassung beherrscht nur das lesen und schreiben von Typ String!
Aber dafür mit allen der Klasse bis jetzt zur Verfügung stehenden Features.

hier ein ausschnitt meiner unit, falls ich euer Interesse geweckt haben sollte, alles was man benötigt um loszulegen liegt diesem Anhang bei, nur kein 7Zip entpacker.
Eine Demo liegt nicht bei, da es hoffentlich selbsterklärend ist, feedback dazu wäre Wünschenswert.
Delphi-Quellcode:
(*

Project: Class TIniHelper

Author: KodeZwerg

License: Freeware, Open Source.
        Free to use, if used and you like it a mentioned thankyou in credits would be nice.
        Feedback on one of my running Project sites is also very welcome, in good or bad way!

Description: small Unit to help easy interact with .ini files

features:
- support autogeneration on many aspects
- auto-mode supports either locate "X:\Users\UserName\AppData\Local\CurrentExeName\" or folder of CurrentExeName
- support easy sub-folder usage simply by adding "a sub\folder in\a sub\filename.ext" with or without leading slash
- you can specify full path + filename if you like else its autogenerated for you
- simple XOR encryption for ini file internals included if you enable it
- AES128 encryption for ini file values can be added
- simple autogenerate password feature for AES128 included
- easy Password changing possible

Limits:
- ATM bound to Windows.

Supported Pascal Versions:
- in theory all, written for >= Delphi 2009
- Prior Delphis might have trouble with UniCode
- Delphi with other Namespace will be supported soon

History:
- created as single methods to test things out
- added encryption for each method
- switched to class

current Version:
- preview release to show whats comming with full access on everything

Status:
- first open release
- pre-release has full control on properties, sideeffects very possible!!
- just included Type String to play with
- with all above features, you might find out more by happy testing :-]

Bugs:
- none know ATM... *yay*
- just missing all other types

Planned:
- include all missing
- fix all, like my current datetime convert issue where i prior need to set formatsettings, i hope than all be good with it

Used external Resources:
- wcrypt2.pas (included)
- independend AES128 example based on wcrypt2.pas (included)
- wcrypt2.pas dependend file encryption example (included) that later be used to crypt streams...
  wish me luck ;-)
- many threads on www.delphipraxis.net and nice discussions with good members over there *thankyou all!*
- stackoverflow i guess always involved to me :))

Project Sites: (latest file will be same)
- German Version: https://www.delphipraxis.net/198462-kodezwergs-tinihelper-klasse.html
- English Version: https://en.delphipraxis.net/topic/175-windows-ini-file-helper-unit/
- you need to sign up free membership to join discussion or download latest file

*)


type
  TIniHelper = class (TObject)
  private
    FAutoFolder: Boolean;
    FCrypt: Boolean;
    FSectionCrypt: Boolean;
    FIdentCrypt: Boolean;
    FPassword: String;
    FPasskey: Integer;
    FFilename: String;
    FSection: String;
    FIdent: String;
    FPath: String;
    FPathDelimiter: Char;
    FFileExists: Boolean;
    procedure SetFilename( const Filename: String = '' );
  published
    constructor Create( const Filename: string = ''; const AutoFolder: boolean = False; const Password: String = ''; const Crypt: Boolean = False; const Passkey: Integer = 0; const SectionCrypt: Boolean = False; const IdentCrypt: Boolean = False; const Section: String = ''; const Ident: String = ''; const PathDelimiter: Char = PathDelim );
    destructor Destroy; override;

    procedure Reset;
    procedure Init( const Section: string = ''; const Ident: string = '' );
    property Filename: string read FFilename write SetFilename;

    property AutoFolder: boolean read FAutoFolder write FAutoFolder;
    property Password: string read FPassword write FPassword;
    property Passkey: integer read FPasskey write FPasskey;
    property Section: string read FSection write FSection;
    property Ident: string read FIdent write FIdent;
    property Crypt: boolean read FCrypt write FCrypt;
    property SectionCrypt: boolean read FSectionCrypt write FSectionCrypt;
    property IdentCrypt: boolean read FIdentCrypt write FIdentCrypt;
    property PathDelimiter: Char read FPathDelimiter write FPathDelimiter;

    function ReadString( const Ident: string = ''; const Default: String = '' ): String;
    function WriteString( const Ident: string = ''; const Value: String = '' ): Boolean;
  end;
passende aufrufe sehen dann so aus:
Delphi-Quellcode:
uses IniHelper;

...

var
  ini: TIniHelper;
begin
  ini := TIniHelper.Create(); // hier kann man alles mögliche initialisieren oder auch nichts, klappt alles hoffentlich ;-)

  ini := TIniHelper.Create( 'ininame.ext', True ); // so initialisiert man etwas was im AppData landet

// mit weiteren Werten der Create methode steuert man verschlüsselung
// hier ein komplexes Beispiel um standards nur einmal festlegen zu müssen
  ini := TIniHelper.Create( 'filename.ext', false, 'Mein AES Passwort', True, -967283, True, True, 'Setup' );


  if ini.WriteString('','x') = false then // schon hat man was in einer datei geschrieben... oder auch nicht, das zeigt diese auswertung
    Memo1.Lines.Add( 'Class write fail' )
    else
    Memo1.Lines.Add( 'Class write success' );

  ini.Filename := 'bla test\test.zwo'; // man kann jederzeit easy datei wechseln, mit oder ohne pfad

  ini.Init('was auch immer'); // so man kann jederzeit sein "root" wechseln oder beibehalten oder leer lassen :)
Viel Spass beim Testen wünscht KodeZwerg.
Angehängte Dateien
Dateityp: 7z IniHelper.7z (58,6 KB, 29x aufgerufen)
Gruß vom KodeZwerg

Geändert von KodeZwerg ( 5. Nov 2018 um 02:06 Uhr) Grund: updated
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:12 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