Witam,
chcę żeby program po uruchomieniu sprawdził w rejestrze czy użytkownik zapisał w nim hasło, czy może ma się o nie zawsze pytać po uruchomieniu. Zrobiłem prostą foremkę, z jednym TEdit i TButton. Tylko że cokolwiek bym nie chciał zrobić z tą małą formą, zawsze mam:
Debugger Exception Notification
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 0046ED1E in module 'Project1.exe'. Read of address 000002FC'. Process stopped. Use Step or Run to continue.
Kod Form1 wygląda mniej-więcej tak:
{$I mysqlinc.inc}
unit Unit1;
interface
uses
Unit2, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, Spin, uMysqlVio, uMysqlCT,
uMysqlClient, uMysqlHelpers, Registry;
type
TForm1 = class(TForm)
{ ... komponenty ... }
procedure SQLReconnectAndSaveClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
MySQLClient: TMySQLClient;
Registry: TRegistry;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Registry:=TRegistry.Create;
MySQLClient:=TMySQLClient.create;
if(Registry.OpenKey('Firma', true)) then
begin
{ ... }
if(Registry.ReadBool('SQLPassAskAtStart')) then
begin
SQLPassAskAtStart.Checked:=True;
Form2.Button1.Caption:='Hello'; { <<<=== tą linię zaznacza delphi na niebiesko }
end
else
begin
SQLPassAskAtStart.Checked:=False;
SQLPass.Text:=Registry.ReadString('SQLPass');
end;
{ ... }
end
else ShowMessage('Nie udało się otworzyć rejestru!');
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
MySQLClient.close;
StatusBar1.Panels.Items[0].Text:='Stan MySQL: Rozłączony';
MySQLClient.Free;
Registry.Free;
end;
end.
Tym bardziej jestem sfrustrowany, że niedawno pisałem inny program, gdzie odwołania do innych form robiłem identycznie...
pozdrawiam
Paweł Lis