Autor Beitrag
Siluro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Di 21.10.08 13:00 
Hi,
hab ein Problem beim Auslesen von Regestrierungsschlüsseln bzw. -werten die ich selbst erstellt hab. Ich komm einfach nicht dahinter wo das Problem liegt. Hier mal mein Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.Button1Click(Sender: TObject);
begin
  reg := TRegIniFile.Create;

  reg.RootKey := HKEY_LOCAL_MACHINE;

  if reg.OpenKeyReadOnly('\SOFTWARE\Microsoft'then begin //funktioniert, gibt true zurück
    showmessage(reg.ReadString('.NETFramework''InstallRoot''C:\'));
  end;

  if reg.OpenKeyReadOnly('\SOFTWARE\Test'then begin //funktioniert nicht, gibt false zurück
    showmessage(reg.ReadString('test2''wert''0'));
  end;
end;

Hat vielleicht jemand einen Vorschlag was man da probieren könnte. Danke schonmal im Vorraus und Grüße

Björn

Im Anhang nochmal ein Screenshot von der Regestry
Einloggen, um Attachments anzusehen!


Zuletzt bearbeitet von Siluro am Di 21.10.08 17:43, insgesamt 1-mal bearbeitet
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Di 21.10.08 13:17 
Ich könnte mir vorstellen, dass das 2. OpenKey im Bezug zum ersten gesucht wird (also quasi ein Unter"ordner" davon), dort aber nicht gefunden wird.

Entweder vorher CloseKey, oder das erste OpenKey rausnehmen.

_________________
PROGRAMMER: A device for converting coffee into software.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 21.10.08 13:18 
Beim zweiten Mal OpenKeyReadOnly wird nicht wieder von der Wurzel HKEY_LOCAL_MACHINE ausgegangen, sondern von dem zuvor geöffneten Zweig.

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Siluro Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Di 21.10.08 13:40 
Danke für die schnellen Antworten, aber das ist nicht das Problem. Ich hab immer entweder das eine oder das andere Auskommentiert, habs jetzt nur wegen der besseren Lesbarkeit beides aktiv.

Björn
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 21.10.08 14:08 
äh mal ne Frage: Wieso denn eigentlich TRegIniFile und nicht TRegistry?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Siluro Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Di 21.10.08 14:13 
Arbeite an einer Software aus meinem Betrieb und da wurde halt TRegIniFile verwendet. Der von mir gepostete Code war zum Test gedacht, weil die Software nichtmehr richtig läuft seit dem ich einen neuen Arbeitsrechner mit XP64 hab. Mich wundert halt nur, dass es mit Einträgen die vom System erzeugt wurden funktioniert und mit einträgen die ich in die Registry schreibe nicht.

Björn

EDIT: Das gleiche Problem gibts auch bei TRegistry

LÖSUNG:
Die Lösung ist ganz einfach. Es ist garkein Problem mit dem Auslesen der Registry. Bei XP64 gibt es unter "SOFTWARE" den Schlüssel "Wow6432Node" in dem die Einträge aus "SOFTWARE" stehen. Das Heisst wenn ich unter Delphi "HKEY_LOCAL_MACHINE\SOFTWARE\..." auslese, wird eigentlich "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\..." aus der Registry ausgelesen. Trotzdem danke für eure Hilfe.

Gruß

Björn