Autor Beitrag
gamer94
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 41

Win7 HP, WinXP
Delphi 7 Pers.
BeitragVerfasst: Do 04.10.07 20:30 
Ich versuche für ein kleines Tool den Pfad eines Spiels aus der Registry auszulesen und in ein Label zu laden. Mein gesamter Quelltext:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, registry;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  regist: TRegistry;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
regist.Create;
try
regist.RootKey := HKEY_LOCAL_MACHINE;
regist.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{907B4640-266B-4A21-92FB-CD1A86CD0F63}',false);
label1.Caption:= regist.ReadString('Contact')
except
Label1.Caption:='WR nicht installiert';
end;

end;
end.


Aber immer wenn ich es ausführe und auf den Button klicke kommt immer der Fehler: Zugriffsverletzung bei Adresse 004254F2 in Modul 'Project1.exe'. Lesen von Adresse 00000008.

Wo liegt hier der Fehler?
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Do 04.10.07 20:44 
Hallo,
user profile icongamer94 hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button1Click(Sender: TObject);
begin
regist.Create;
try
{...}

so geht das ja auch nicht. Wie uns jedes Delphi Tutorial verrät muss es regist := TRegistry.Create heißen ;).

Gruß
Klabautermenn