Autor |
Beitrag |
rubooo
      
Beiträge: 52
WIN XP
Delphi 2005 Prof
|
Verfasst: Mi 21.06.06 12:47
warum komm denn hier eine Zugriffsverletzung. ist es anderst möglich die Form zu verstecken?
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:
| unit telnet;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPServer, IdTelnetServer, IdAntiFreezeBase, IdAntiFreeze, idContext;
type TForm1 = class(TForm) IdTelnetServer: TIdTelnetServer; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure IdTelnetServerExecute(AContext: TIdContext); procedure IdTelnetServerAuthentication(AContext: TIdContext; const AUsername, APassword: string; var AAuthenticated: Boolean); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.IdTelnetServerAuthentication(AContext: TIdContext; const AUsername, APassword: string; var AAuthenticated: Boolean);
label richtig,falsch; begin
AAuthenticated:=false; if AUsername='test' then begin goto richtig; end else acontext.Connection.IOHandler.WriteLn('Anmeldung nicht erfolgreich.'); acontext.Connection.Disconnect; richtig: if APassword='123' then begin acontext.Connection.IOHandler.WriteLn('Anmeldung erfolgreich.'); acontext.Connection.IOHandler.WriteLn(''); AAuthenticated:=True; end;
end;
procedure TForm1.IdTelnetServerExecute(AContext: TIdContext); var befehl: String; begin with acontext.Connection.IOHandler do begin befehl:=ReadLn;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject); begin idTelnetServer.Active := False; end;
procedure TForm1.FormCreate(Sender: TObject); begin ShowWindow(Application.MainForm.Handle, SW_HIDE); end;
end. |
Moderiert von raziel: Topic aus Internet / Netzwerk verschoben am Mi 21.06.2006 um 15:36
|
|
uall@ogc
      
Beiträge: 1826
Erhaltene Danke: 11
Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
|
Verfasst: Mi 21.06.06 13:35
Sofern MainForm noch nicht erstellt wurde kannst du in Form1 darauf nicht zugreifen.
Application.MainForm.Handle <- crashed
Erstell Mainform halt vor Form1. dann sollte es gehen (steht in der Project.dpr)
Zum Codestil: Bitte vermeide die Benutzung von Labels (richtig/falsch) 
_________________ wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
|
|
rubooo 
      
Beiträge: 52
WIN XP
Delphi 2005 Prof
|
Verfasst: Mi 21.06.06 14:32
sorry aber wie muss ich das machen erstellen?!!? keine ahnung wie du das meinst. kannst du mir evtl. ein codebsp. geben?
und warum keine labels benutzen. was an stelle von diesen sollte man besser benutzen ?
|
|
Marco D.
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Mi 21.06.06 15:05
Du versuchst auf die Mainform zuzugreifen, bevor sie überhaupt erstellt (created) wurde. Da diese beim Zugriff also nicht vorhanden ist, gibts eine Zugriffsverletzung. Schreib einfach die Zeile aus OnCreate in OnShow.
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
rubooo 
      
Beiträge: 52
WIN XP
Delphi 2005 Prof
|
Verfasst: Mi 21.06.06 15:44
wenn ichs in onShow einsetz verschwindet Sie aber garnicht....
|
|
Marc.
      
Beiträge: 1876
Erhaltene Danke: 129
Win 8.1, Xubuntu 15.10
|
Verfasst: Mi 21.06.06 15:46
setz es einfach bei OnActivate ein 
|
|
fidionael
      
Beiträge: 232
Win XP SP2, Ubuntu 6.06
Delphi 7 PE, Delphi 3 Prof
|
Verfasst: Mi 21.06.06 16:29
|
|
rubooo 
      
Beiträge: 52
WIN XP
Delphi 2005 Prof
|
Verfasst: Mi 21.06.06 16:51
mit OnActivate klappts auch nicht ! krieg ich auch ne fehlermeldung!
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
| program telnet1;
uses Forms, telnet in 'telnet.pas' ;
{$R *.res}
begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.MainForm.Hide; Application.Run; end. |
und so passiert garnichts....
wo ist mein fehler?
|
|
Born-to-Frag
      
Beiträge: 1094
Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
|
Verfasst: Mi 21.06.06 17:02
_________________ Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
|
|
rubooo 
      
Beiträge: 52
WIN XP
Delphi 2005 Prof
|
Verfasst: Mi 21.06.06 17:20
|
|