Autor Beitrag
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mo 21.02.05 20:03 
Hallo, wenn ich in meinem Prog ein neues Form öffne kommt die Fehlermeldung "Zugriffsverletzung auf Adresse ..."
Wenn ich das erste Form deaktiviere sage ich :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
reg:TRegistry;

...
reg.free;

Form3.show;
...

Form 3:
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:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
unit new;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, XPMan,Registry;

type
  TForm3 = class(TForm)
    description: TMemo;
    pword: TLabeledEdit;
    uname: TLabeledEdit;
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    titel: TLabeledEdit;
    XPManifest1: TXPManifest;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormActivate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form3: TForm3;
  reg2:TRegistry;
  i:integer;
  anfang:string;
  versch:boolean;
implementation

uses main;

{$R *.dfm}

function verschluesseln (anfang:string):string;
var
 s : string;
 i : Integer;
begin
 reg2.OpenKey('\SOFTWARE\TopSecu\',false);
 If versch = true then
 begin
  s :=anfang;
  for i := 1 to length(s) do
   s[i] := char(strtoint(reg2.ReadString('key_'+inttostr(i))) xor byte(s[i]));

  result := s;

 end else
 begin
  s := anfang;
  For i := 1 to length(s) do
   s[i] := char(strtoint(reg2.ReadString('key_'+inttostr(i))) xor byte(s[i]));

  result := s;

 end;
end;

procedure TForm3.Button1Click(Sender: TObject);
begin
   versch:=true;
   anfang:=titel.text;
   titel.Text:=verschluesseln(anfang);
   reg2.WriteString('Titel_'+inttostr(i),titel.Text);
   Form2.itemlist.Items.Add(titel.Text);
   Form2.show;
   Form3.Close;
end;

procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);
begin
reg2.Free;
end;

procedure TForm3.FormActivate(Sender: TObject);
begin
   reg2.Create;
   reg2.RootKey:=HKEY_LOCAL_MACHINE;
   reg2.OpenKey('\SOFTWARE\TopSecur',false);
end;

procedure TForm3.FormDestroy(Sender: TObject);
begin
   reg2.Free;
end;

end.

Kann mir jemand helfen?
Invulnerabilis
//edit: www.vonrueti.ch/Passwd.rar
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 21.02.05 20:14 
Wie wärs mit Application.CreateForm von Form3? Außerdem: r2 := TRegistry.Create!

AXMD
Christian V. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mo 21.02.05 20:17 
Danke, und:
AXMD hat folgendes geschrieben:
Wie wärs mit Application.CreateForm von Form3?

AXMD

Was meinst du damit?
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mo 21.02.05 20:19 
Wenn Form3 nicht per Application.CreateForm(TForm3, Form3) aufgerufen wird bekommst du eine AV; außer du lässt das von Delphi regeln...

AXMD
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 21.02.05 20:45 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm3.FormClose(Sender: TObject; var Action: TCloseAction);  
begin  
reg2.Free;  
end;  

procedure TForm3.FormDestroy(Sender: TObject);  
begin  
   reg2.Free;  
end;

Siehst du es jetzt? Und warum auch hier wieder alles global? Langsam solltets du selber sehen, dass du dir deine Probleme damit nur selber machst.