Autor Beitrag
ex4ct
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mi 12.04.06 17:49 
Hallo,
Ich will möchte einen Programm machen das,
wenn eine Internetverbindung hergestellt wurde eine Internetseite im Browser öffnet!
Leider weis ich nicht wie ich das machen soll.

BsP:
ausblenden Delphi-Quelltext
1:
2:
if "internetverbindung da" then begin
ShellExecute(0,NIL,'www.beispiel.de',NIL,NIL,SW_Normal);
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Mi 12.04.06 18:10 
Versuch doch mit den Indys einen Ping zu senden, und wenn er zuück kommt öffnest du die page

//@ex4ct Mein Prog tut jetzt, auch mit Bild :-D

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mi 12.04.06 18:23 
Das Programm soll nicht nur am anfang gucken ob eine Internetverbindung besteht.
Wenn keine Inet-Verbindung da ist soll es nach 10 sek wieder gucken.
-> Tut mir leid, ich bin noch ein Anfänger :-(
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mi 12.04.06 19:05 
Hab jetzt eine gute Lösung gefunden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
uses
 WinInet;

procedure TForm1.FormCreate(Sender: TObject);
begin
  if InternetGetConnectedState(nil0then
  begin
    Edit1.Text := 'ONLINE';
  end
  else
  begin
    Edit1.Text := 'OFFLINE';
  end;
end;


Aber der soll halt wenn keine VErbindung da ist nach 10 sek wieder gucken!
Einloggen, um Attachments anzusehen!
Watsch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 97

Win98 SE
D3 Prof, D4 C/S
BeitragVerfasst: Mi 12.04.06 19:15 
Pack doch den Internet-Check in das OnTimer-Ereignis der Timer-Komponente.
Intervall = 10000 (<- entspricht 10 Sek.)
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mi 12.04.06 19:21 
user profile iconWatsch hat folgendes geschrieben:
Pack doch den Internet-Check in das OnTimer-Ereignis der Timer-Komponente.
Intervall = 10000 (<- entspricht 10 Sek.)

Cool es geht, danke dir!


Zuletzt bearbeitet von ex4ct am Mo 10.07.06 14:26, insgesamt 1-mal bearbeitet
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mi 12.04.06 19:57 
user profile iconWatsch hat folgendes geschrieben:
Pack doch den Internet-Check in das OnTimer-Ereignis der Timer-Komponente.
Intervall = 10000 (<- entspricht 10 Sek.)

Hmmm...das geht doch nicht!
Wenn ich z.B. die ganze zeit online bin, dann öffnet das Programm doch jede 10 sekunden die Seite!:S:S
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 12.04.06 20:05 
Dann deklariere eben noch eine Boolean Variable und setze diese auf True wenn du die Seite geöffnet hast und öffne nur eine Seite wenn sie auf False steht


greetz

_________________
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.
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 12.04.06 20:11 
user profile iconex4ct hat folgendes geschrieben:
Hab jetzt eine gute Lösung gefunden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
uses
 WinInet;

procedure TForm1.FormCreate(Sender: TObject);
begin
  if InternetGetConnectedState(nil0then
  begin
    Edit1.Text := 'ONLINE';
  end
  else
  begin
    Edit1.Text := 'OFFLINE';
  end;
end;


Aber der soll halt wenn keine VErbindung da ist nach 10 sek wieder gucken!


Die lösung ist sehr schlecht, funktioniert nämlich nicht bei Leuten die hinter einem Router sind..

_________________
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.


Zuletzt bearbeitet von Born-to-Frag am Mi 12.04.06 20:26, insgesamt 1-mal bearbeitet
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mi 12.04.06 20:25 
Ich habe keinen Router, aber bei mir funktionierts!
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 12.04.06 20:25 
user profile iconex4ct hat folgendes geschrieben:
Ich habe keinen Router, aber bei mir funktionierts!


Bei Leuten die hinter einem Router sind funktioniert es aber nicht :roll:

EDIT: Ja, ich habe beim ersten Edit ein 'nicht' zuviel gesetzt weil ich dachte da fehlt eins :P

_________________
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.
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mi 12.04.06 20:35 
user profile iconBorn-to-Frag hat folgendes geschrieben:
Dann deklariere eben noch eine Boolean Variable und setze diese auf True wenn du die Seite geöffnet hast und öffne nur eine Seite wenn sie auf False steht
greetz

Das mit dem Boolean hab ich nicht ganz verstanden könntest du hier einen kleinen Beispiel geben?
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 12.04.06 20:50 
user profile iconex4ct hat folgendes geschrieben:
Das mit dem Boolean hab ich nicht ganz verstanden könntest du hier einen kleinen Beispiel geben?


Deklariere eine globale Variable (da wo steht "Form1: TForm1"). Nennen wir sie 'geoeffnet'.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
var
  Form1: TForm1;
  ...
  Geoeffnet: Boolean = False;


Und so öffnest du die Seite dann:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
 if (InternetGetConnectedState(nil0)) and (not geoeffnet) then
  begin
    Geoeffnet := True
    // Seite laden
  end
  else ShowMessage('ScheissDieWandAn');

_________________
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.
ex4ct Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67


Delphi 7
BeitragVerfasst: Mi 12.04.06 21:10 
Aha, ist ja eigentlich leicht...danke an alle die mit geholfen haben!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 12.04.06 23:22 
Moin!

Der Vollständigkeit halber: man kann nicht erkennen, ob eine Internetverbindung besteht. Guckst du hier. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mi 12.04.06 23:40 
user profile iconNarses hat folgendes geschrieben:
Moin!

Der Vollständigkeit halber: man kann nicht erkennen, ob eine Internetverbindung besteht. Guckst du hier. ;)

cu
Narses


Da hast du wohl Recht, Ping ist aber IMHO doch ein bisschen zuverlässiger als InternetGetConnectedState..


greetz

_________________
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.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 13.04.06 09:35 
Moin!

user profile iconBorn-to-Frag hat folgendes geschrieben:
Ping ist aber IMHO doch ein bisschen zuverlässiger als InternetGetConnectedState

Sorry, aber einen Ping abzusetzen ist das allerletze... :| ;) (ist nicht persönlich gemeint!) Ich erinnere an den Router mit dial-up-connection aus o.g. Quelle :arrow: der wählt dann ein, statt zu melden, ob er eingewählt ist... :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Do 13.04.06 10:31 
OK ganz einfach:
einfach mit der ClientSocket Komponente den Host auf die Google IP und Port auf 80 setzen.
dann schick im OnConnect ereignis ein Sendtext an google, mit Try Except.
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:
..Onconnect ...
begin
  Try begin
     ClientSocket1.Socket.SendText('Hallo ist da wer?');
     online:=True; 
      end;        
   except online:= False;
  end;
ClientSocket1.CLose;
end;

//So jetzt wissen wir ob du online bist oder nicht.
//Online wird nur False wenns nen Fehler gibt :-)
//Ach ja im ErrorEvent ErrorCode auf 0 setzen.
//error Code dauert eh viel zu lange bis es was meldet.

... Dein Timer
begin
  If error = True Then begin
   //Internetseite öffnen
  Timer1.Enabled:=False; 
  end;

end;

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 13.04.06 10:49 
Moin!

user profile iconFighter#1 hat folgendes geschrieben:
OK ganz einfach:
einfach mit der ClientSocket Komponente den Host auf die Google IP und Port auf 80 setzen.
dann schick im OnConnect ereignis

:roll: Nix einfach, gleiches Problem: es wird eine Verbindung aufgebaut, wenn keine besteht, statt zu melden, ob eine besteht... :|

Leute, ES GEHT EINFACH NICHT, der Rechner kann nicht selbst zweifelsfrei herausfinden, ob er online ist! :mahn:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Do 13.04.06 10:53 
Bitte alles durchlesen!
wenn man text hinsendet und er findet google nicht dann ruft er die Eception sofort aus.
Getestet!
Mit Router :-D

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse