Autor Beitrag
michaelarban
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Di 03.04.12 10:15 
Hallo,

ich habe eine Konfigurationsdatei (myConfig.conf), die Key-Value-Paare enthält, jedoch KEINE Seltionen. Diese Konfig-Datei wird von einer C-DLL ausgelesen.

Bsp:
ausblenden Quelltext
1:
2:
3:
#das ist ein Kommenatar
Key1=On
Key2=123

Ich versuche, per Delphi den Key1=On in Key1=Off zu setzen, was jedoch zu einer Zugriffsvereltzung im Modul ntdll.dll führt.
ausblenden Delphi-Quelltext
1:
myConfigFile.WriteString('''Key1''Off');//was kann ich als Sektionswert angeben?					

Liegt es daran, dass die Konfig-Datei keine Sektionen hat?

danke

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Di 03.04.2012 um 11:26
Nersgatt
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1581
Erhaltene Danke: 279


Delphi 10 Seattle Prof.
BeitragVerfasst: Di 03.04.12 11:12 
Du könntest eine TStringList dafür verwenden. Auf die Wertpaare kannst Du mit TStringList.Values zugreifen.

_________________
Gruß, Jens
Zuerst ignorieren sie dich, dann lachen sie über dich, dann bekämpfen sie dich und dann gewinnst du. (Mahatma Gandhi)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 03.04.12 11:28 
Moin!

user profile iconmichaelarban hat folgendes geschrieben Zum zitierten Posting springen:
ich habe eine Konfigurationsdatei (myConfig.conf), die Key-Value-Paare enthält, jedoch KEINE Seltionen.
Naja, dann packste halt eine Dummy-Sektion [Global] oder sowas da mit rein, fertig. Ist das verboten? :nixweiss:

user profile iconmichaelarban hat folgendes geschrieben Zum zitierten Posting springen:
Liegt es daran, dass die Konfig-Datei keine Sektionen hat?
Ja, die API-Funktionen verwenden immer eine Sektion. Alternativ ginge vielleicht auch ein TMemIniFilem, das nutzt IIRC auch keine API-Funktionen. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
michaelarban Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Di 03.04.12 12:49 
danke,

ich werde dann wohl oder übel eine dummy-Section nehmen.


danke
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Di 03.04.12 19:34 
user profile iconNarses hat folgendes geschrieben Zum zitierten Posting springen:
Ja, die API-Funktionen verwenden immer eine Sektion. Alternativ ginge vielleicht auch ein TMemIniFilem, das nutzt IIRC auch keine API-Funktionen. :idea:
Ohne Section funktioniert das auch nicht.

Daher ist das einfachste ohne das Datenformat zu ändern:
user profile iconNersgatt hat folgendes geschrieben Zum zitierten Posting springen:
Du könntest eine TStringList dafür verwenden. Auf die Wertpaare kannst Du mit TStringList.Values zugreifen.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Lemmy
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 792
Erhaltene Danke: 49

Windows 7 / 10; CentOS 7; LinuxMint
Delphi 7-XE10.1, VS 2015
BeitragVerfasst: Di 03.04.12 20:52 
user profile iconmichaelarban hat folgendes geschrieben Zum zitierten Posting springen:
danke,
ich werde dann wohl oder übel eine dummy-Section nehmen.


Warum ein Auto mit Benzinmotor kaufen und sich dann beschweren, dass man keinen DIesel tanken kann? Es gibt für das Problem doch zig Möglichkeiten, wobei die TStringList sicher das trivialste ist...
Tranx
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 648
Erhaltene Danke: 85

WIN 2000, WIN XP
D5 Prof
BeitragVerfasst: Mi 04.04.12 15:32 
Frage, warum benennst Du die Sektion nicht "KeyVariablen" oder "Key"? Dann kannst Du in der Config-Datei auch andere Dinge speichern und hast sie getrennt, weil sie in einer anderen Sektion stehen.

_________________
Toleranz ist eine Grundvoraussetzung für das Leben.