Autor Beitrag
chall_de
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

WIN 2000, WIN XP

BeitragVerfasst: Mo 15.08.05 08:08 
Hallo,

folgender Code verursacht bei mir beim Beenden des Programms einen Runtime Error 216:

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:
29:
...

implementation

{$R *.dfm}
uses Printers;

var dst: TStrings;

procedure TForm1.FormCreate(Sender: TObject);

begin
  dst := TStringList.Create;
  dst := Printer.Printers;
  Listbox1.Items := dst;
  Listbox1.ItemIndex := Printer.PrinterIndex;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  dst.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form1.Close;
end;

end.


Was mache ich falsch ???

Gruß,

chall_de
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Mo 15.08.05 08:26 
Dein Fehler ist, dass dst nicht mehr auf die von die erstellte Stringliste, sondern direkt auf Printer.Printers zeigt. Diese Liste darfst du natürlich nicht freigeben.
Ändere deine Zuweisung in

ausblenden Delphi-Quelltext
1:
dst.Text := Printer.Printers.Text					

_________________
Bravery calls my name in the sound of the wind in the night...
chall_de Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

WIN 2000, WIN XP

BeitragVerfasst: Mo 15.08.05 08:43 
Hallo noidic,

alles klar! Vielen Dank ...


Gruß,

chall_de