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 22:46 
Hallo, ich habe drei Forms, Form 1 ist das Hauptform, und doch erscheint Form2 auch schon beim Start des Programms, Form3 jedoch nicht. Woran kann das liegen?
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Mo 21.02.05 22:51 
da sag ich nur: CODE, BITTE! :twisted:
sonst kann ich nur raten und rate folgendes
ausblenden Delphi-Quelltext
1:
2:
form2.visible = TRUE;
form3.visible = FALSE;

:?:

_________________
[inspirationslos]
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 22:55 
Form 2
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:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
unit main;

interface

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

type
  TForm2 = class(TForm)
    itemlist: TListBox;
    uname: TLabeledEdit;
    passwd: TLabeledEdit;
    new: TButton;
    XPManifest1: TXPManifest;
    procedure newClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure itemlistClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  versch:boolean;
  reg:Tregistry;
  Form2: TForm2;
  endversch,anfang,pswdtext:string;
  I:integer;
implementation

uses new, pswd;

{$R *.dfm}
function verschluesseln (anfang:string):string;
var
 s : string;
 i : Integer;
begin
 reg.OpenKey('\SOFTWARE\TopSecu\',false);
 If versch = true then
 begin
  s :=anfang;
  for i := 1 to length(s) do
   s[i] := char(strtoint(reg.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(reg.ReadString('key_'+inttostr(i))) xor byte(s[i]));

  result := s;

 end;
end;

procedure TForm2.newClick(Sender: TObject);
begin
Form3.show;
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin

Form1.Close;
end;

procedure TForm2.itemlistClick(Sender: TObject);
var
m:integer;
begin
reg:=Tregistry.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('\SOFTWARE\TopSecur',false);
firststart:=false;

anfang:=reg.ReadString('uname_'+inttostr(strtoint(itemlist.Items[ itemlist.ItemIndex ])+1));

uname.Text:=verschluesseln(anfang);

//endversch:=
//if itemlist.selected[m] then uname.text := itemlist.items[m]
reg.Free;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
Form2.Width:=298;
reg:=Tregistry.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('\SOFTWARE\TopSecur',false);

For I:= 0 to reg.ReadInteger('HowMany') do begin
   firststart:=false;
   anfang:=reg.ReadString('titel_'+inttostr(i));
   endversch:=verschluesseln(anfang);
   itemlist.Items.Add(endversch);
end;
reg.Free;
end;

end.

Form 1:
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:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
unit pswd;

interface

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

type
  TForm1 = class(TForm)
    OK: TButton;
    pswd1: TLabeledEdit;
    pswd2: TLabeledEdit;
    XPManifest1: TXPManifest;
    procedure OKClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;
const
 code = 3;
var
   superkey : array[1..255] of byte;
  Form1: TForm1;
  reg:TRegistry;
  zwischen,fertig:int64;
  firststart:boolean;
  pswdtext,anfang,versch:string;
implementation

uses main;

{$R *.dfm}

function verschluesseln (anfang:string):string;
var
 s : string;
 i : Integer;
begin
 reg.OpenKey('\SOFTWARE\TopSecu\',false);
 If firststart = true then
 begin
  s :=anfang;
  for i := 1 to length(s) do
   s[i] := char(strtoint(reg.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(reg.ReadString('key_'+inttostr(i))) xor byte(s[i]));

  result := s;

 end;
end;

procedure TForm1.OKClick(Sender: TObject);
begin
reg.OpenKey('\SOFTWARE\TopSecur',false);
if pswd2.Visible=true then begin
   if pswd1.Text=pswd2.Text then begin
      firststart:=true;
      anfang:=pswd1.Text;
      pswd1.Text:=verschluesseln(anfang);
      reg.WriteString('pwd',pswd1.Text);
      Form2.show;
      reg.Free;
      Form2.Visible:=true;
      Form1.Visible:=false;
   end;
end
else begin
      firststart:=false;
      anfang:=pswd1.Text;
      pswd1.Text:=verschluesseln(anfang);
   if pswd1.Text=reg.ReadString('pwd') then begin
      reg.Free;
      Form2.Show;
      Form1.Visible:=false;
   end;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
 blabla:string;
 i : Integer;
begin



reg := TREgistry.Create;
reg.RootKey:=HKEY_LOCAL_MACHINE;
if reg.KeyExists('\SOFTWARE\TopSecur') then begin
   pswd2.Visible:=false;
end
else
reg.CreateKey('\SOFTWARE\TopSecur');
reg.OpenKey('\SOFTWARE\TopSecur',false);
if reg.KeyExists('HowMany') then begin
end
else begin
reg.WriteInteger('HowMany',0);
end;

 randseed := code;

 for i  := 1 to high(superkey) do begin
  superkey[i]:=random(255);

  reg.Writestring('key_'+inttostr(i),inttostr(superkey[i]));

  end;

end;


end.

Und die Projektdatei:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
program Password;

uses
  Forms,
  pswd in 'pswd.pas' {Form1},
  main in 'main.pas' {Form2},
  new in 'new.pas' {Form3};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.CreateForm(TForm3, Form3);
  Application.CreateForm(TForm2, Form2);
  Application.Run;
end.
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Di 22.02.05 16:15 
aus dem code gehz eigentlich nicht so viel hervor. Zumindest nichts, was dazu fährt, das Forms zu früh erscheinen.
Wenn du die Eigenschaft Visible der Forms überprüft hast (im objekt inspektor), müsstes eigentlich gehn. Sprich Form2.Visible auf False setzen und erst dann auf TRUE, wenn es zu sehen sein soll. Das selbe gilt natürlich auch für Form3.
Noch Fragen? 8) :D

_________________
[inspirationslos]