Autor Beitrag
Hendi48
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 17.06.07 10:02 
Hi, also ich hab das hier (im FormCreate)
ausblenden 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:
var
reg: TRegistry;
RunWizard: Boolean;
begin
  reg:=TRegistry.Create;
  try
  Reg.Rootkey:=HKEY_CURRENT_USER;
  if Reg.OpenKey('\Software\iCheat',true) then
  RunWizard:=reg.ReadBool('Run Wizard');


    if Runwizard=true then
   begin
   Reg.DeleteKey('First Time User');
   Reg.DeleteKey('language Deutsch');
   Reg.DeleteKey('Language English');
   Reg.DeleteKey('CT automatisch laden');
   end
    else
    reg.WriteBool('Safed',true);
    ShellExecute(0,'open','Data.exe','','',sw_show);
    Close;
    Application.Terminate;

finally
reg.free;
  end;
end;

Nur wenn halt Run Wizard in der Regi nich existiert kommt "Fehler beim Holen der Daten für Run Wizard!". Wie kann ich vermeiden das das kommt? Geht das mit if not Reg.KeyExists('Run Wizard') ... ?
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: So 17.06.07 10:05 
Ja, das sollte gehen, aber...

... probiers doch einfach aus.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 17.06.07 10:08 
ja nur wo soll ich das hin tun? wenn ichs unter RunWizard:=reg.ReadBool('Run Wizard'); tu dann springt der zu else (also er startet data.exe) obwohl der Key nicht existiert
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: So 17.06.07 10:34 
Eigentlich hast du doch ne try...finally drumrum.
Dann sollte es so funktionieren wie du es oben gepostet hast.
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 17.06.07 10:48 
aber wenn ichs einfach so
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:
var
reg: TRegistry;
RunWizard: Boolean;
begin
  reg:=TRegistry.Create;
  try
  Reg.Rootkey:=HKEY_CURRENT_USER;
  if Reg.OpenKey('\Software\iCheat',true) then
  RunWizard:=reg.ReadBool('Run Wizard');
  if not Reg.KeyExists('Run Wizard'then
  begin
   reg.WriteBool('Run Wizard',true);
  end;

    if Runwizard=true then
   begin
   Reg.DeleteKey('First Time User');
   Reg.DeleteKey('language Deutsch');
   Reg.DeleteKey('Language English');
   Reg.DeleteKey('CT automatisch laden');
   end
    else
    reg.WriteBool('Safed',true);
    ShellExecute(0,'open','Data.exe','','',sw_show);
    Close;
    Application.Terminate;

finally
reg.free;
  end;
end;

mach, dann schreibt der gar nich Run Wizard,true in die reg und es kommt wieder der dumme fehler :?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 17.06.07 10:56 
Erst Prüfen ob der Value existiert UND DANN diesen lesen ... Zeile 9 muss also unter den Block Z10-13 ...

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: So 17.06.07 10:58 
Du musst dann schon folgendes schreiben

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
if not Reg.KeyExists('Run Wizard'then
begin
  reg.WriteBool('Run Wizard',true);
  RunWizard := True;
end
else
begin
  RunWizard:=reg.ReadBool('Run Wizard');
end;
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 17.06.07 11:35 
Jetz will der wieder sofort Data.exe starten
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: So 17.06.07 11:39 
Wie lautet den der exakte Wortlaut deiner Fehlermeldung?
Hast du genügend Zugriffsrechte?
Wo genau passiert der Fehler?
Hendi48 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 271



BeitragVerfasst: So 17.06.07 11:45 
also ich poste mal den Kompletten Code: (es is ein Wizard, wo man Einstellungen machen kann und wenn es halt das erste mal gestartet wird soll man den Wizard machen und wenn man den fertig hat startet dann Data.exe. Wenn man dann das nächste mal das Programm startet soll es einfach als Loader agieren und einfach Data.exe starten (vorher wird safe=true in reg geschrieben und das wird dann wieder von Data.exe gelesen und auf false gesetzt (damit man nich einfach so data.exe starten kann))
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:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, JvExComCtrls, JvPageListTreeView, StdCtrls, JvExStdCtrls,
  JvCombobox, JvWizard, JvWizardRouteMapSteps, JvExControls, JvComponentBase,
  JvTrayIcon, JvgLanguageLoader, JvAnimTitle, Registry, shellapi, ExtCtrls,
  Buttons;

type
  TfrmWizard = class(TForm)
    JvWizard1: TJvWizard;
    JvWizardRouteMapSteps1: TJvWizardRouteMapSteps;
    JvAnimTitle1: TJvAnimTitle;
    Label1: TLabel;
    JvWizardWelcomePage1: TJvWizardWelcomePage;
    JvWizardInteriorPage1: TJvWizardInteriorPage;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    JvWizardInteriorPage2: TJvWizardInteriorPage;
    Edit1: TEdit;
    Label5: TLabel;
    JvWizardInteriorPage3: TJvWizardInteriorPage;
    JvWizardInteriorPage4: TJvWizardInteriorPage;
    Button2: TButton;
    Edit2: TEdit;
    Edit3: TEdit;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    Label11: TLabel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    Image1: TImage;
    Label12: TLabel;
    Image2: TImage;
    Label13: TLabel;
    Image3: TImage;
    Image4: TImage;
    ComboBox1: TComboBox;
    Label14: TLabel;
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure SpeedButton4Click(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  frmWizard: TfrmWizard;

implementation

{$R *.dfm}

procedure TfrmWizard.Button2Click(Sender: TObject);
var
reg: TRegistry;
begin
reg:=TRegistry.Create;
  try
    Reg.RootKey := HKEY_CURRENT_USER;
    if Reg.OpenKey('\Software\iCheat',true) then
    begin

      //write the settings
      reg.WriteBool('language Deutsch',radiobutton1.checked);
      reg.WriteBool('language English',radiobutton2.checked);
      reg.WriteString('CT automatisch laden',edit1.Text);
      reg.WriteString('MapleEurope Pfad',edit3.Text);
      reg.WriteString('MapleSEA Pfad',edit2.text);
      reg.WriteBool('Run Wizard',false);
    end;
    if radiobutton1.checked then
    begin
   // if label12.visible=false then
   // showmessage('Bitte wähl ja/nein aus!');
    if label13.visible=false then
    showmessage('Bitte wähl ja/nein aus!');
    end;
    if radiobutton2.checked then
    begin
   // if label12.visible=false then
   // showmessage('Please select yes/no!');
    if label13.visible=false then
    showmessage('Please select yes/no!');
    end;
  finally
    reg.Free;
 

    if image2.visible then
    begin
     ShellExecute(Handle, 'open','Tutorial.exe'nilnil, SW_SHOWNORMAL) ;
    end;
    sleep(5);
    if label13.Visible then
    ShellExecute(Handle, 'open','Data.exe'nilnil, SW_SHOWNORMAL) ;
    close;
  end;
end;

procedure TfrmWizard.ComboBox1Change(Sender: TObject);
begin
edit1.text:=ComboBox1.Items[ComboBox1.ItemIndex];
if combobox1.ItemIndex=3 then
 begin
  edit1.Enabled:=true;
  edit1.Clear;
 end;
end;

procedure TfrmWizard.FormCreate(Sender: TObject);
var
reg: TRegistry;
RunWizard: Boolean;
begin
  reg:=TRegistry.Create;
  try
  Reg.Rootkey:=HKEY_CURRENT_USER;
  if Reg.OpenKey('\Software\iCheat',true) then
  if not Reg.KeyExists('Run Wizard'then
 begin
  reg.WriteBool('Run Wizard',true);
  RunWizard := True;
 end
 else
 begin
  RunWizard:=reg.ReadBool('Run Wizard');  
 end;

    if Runwizard=true then
   begin
   Reg.DeleteKey('First Time User');
   Reg.DeleteKey('language Deutsch');
   Reg.DeleteKey('Language English');
   Reg.DeleteKey('CT automatisch laden');
   end
    else
    reg.WriteBool('Safed',true);
    ShellExecute(0,'open','Data.exe','','',sw_show);
    Close;
    Application.Terminate;

finally
reg.free;
  end;
end;

procedure TfrmWizard.RadioButton1Click(Sender: TObject);
begin
Label5.Caption:='Bitte stell ein, welcher CT nach dem Start immer geladen werden soll:';
jvwizardinteriorpage2.Title.Text:='Cheat Table Einstellungen';
jvwizardinteriorpage3.Title.text:='Schnellstart Optionen';
label6.Caption:='Bitte stell ein, wo folgende Maple''s bei dir sind:';
jvwizardinteriorpage4.Caption:='Letzte Fragen';
label10.Caption:='Willst du .CT Dateien mit iCheat verknüpfen?';
label11.Caption:='Willst du das Tutorial (Englisch!) ausprobieren?';
speedbutton1.Caption:='Ja';
speedbutton3.Caption:='Ja';
speedbutton2.Caption:='Nein';
speedbutton4.Caption:='Nein';
label14.caption:='Anderer:';
end;

procedure TfrmWizard.RadioButton2Click(Sender: TObject);
begin
Label5.Caption:='Please set, which CT always should be loaded after the start:';
jvwizardinteriorpage2.Title.text:='Cheat Table Settings';
jvwizardinteriorpage3.Title.text:='Quickstart Options';
label6.Caption:='Please set, where the following Maple''s are on your PC:';
label10.Caption:='Do you want to associate .CT files with iCheat?';
label11.Caption:='Do you want to try out the Tutorial?';
speedbutton1.Caption:='Yes';
speedbutton3.Caption:='Yes';
speedbutton2.Caption:='No';
speedbutton4.Caption:='No';
Label14.Caption:='Other:';
end;

procedure TfrmWizard.SpeedButton1Click(Sender: TObject);
begin
speedbutton1.enabled:=false;
speedbutton2.enabled:=false;
Label12.Visible:=true;
Image1.Visible:=true;
end;

procedure TfrmWizard.SpeedButton2Click(Sender: TObject);
begin
speedbutton1.enabled:=false;
speedbutton2.enabled:=false;
Label12.Visible:=true;
Image3.Visible:=true;
end;

procedure TfrmWizard.SpeedButton3Click(Sender: TObject);
begin
speedbutton3.enabled:=false;
speedbutton4.enabled:=false;
Label13.Visible:=true;
Image2.Visible:=true;
end;

procedure TfrmWizard.SpeedButton4Click(Sender: TObject);
begin
speedbutton3.enabled:=false;
speedbutton4.enabled:=false;
Label13.Visible:=true;
Image4.Visible:=true;
end;

end.