Autor Beitrag
Borlox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 191

Win XP
Delphi 6 Enterprise
BeitragVerfasst: Di 29.10.02 20:33 
Hi,

ich möchte die Internetverbindung prüfen und habe es versucht mit einem Ping auf eine andere Site zu prüfen, aber ich möchte wenn ich das prüfe nicht, dass er anwählt, wie kann ich das machen?

Mein Code:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.Timer1Timer(Sender: TObject); 
begin 
  NMEcho1.Host:=edit1.text; // host auswählen zb. www.auq.de 
  try NMEcho1.Connect; 
  except; 
end; 
end; 

procedure TForm1.NMEcho1Connect(Sender: TObject); 
begin 
  label1.caption:='Status: Ping!'; 
  NMEcho1.Echo('pling'); // pling kannst du auch durch ping ersetzen 
  label1.caption:='Status: '+FloatToStr(NMEcho1.ElapsedTime)+'ms'; 
  NMEcho1.Disconnect; 
end; 

procedure TForm1.NMEcho1ConnectionFailed(Sender: TObject); 
begin 
  label1.caption:='Status: Falscher Host'; 
end;


Hat jemand eine Idee?

Borlox
DataCool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Di 12.11.02 09:57 
Hi,

der folgende Code die Standard-Internetverbindung, wenn eine eingerichtet ist.

function ConnectWWW : Boolean;
var
dwConnectionTypes: DWORD;
begin
result := true;
dwConnectionTypes := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
//if not InternetGetConnectedState(@dwConnectionTypes, 0) then
// not connected
if not InternetAutodial(INTERNET_AUTODIAL_FORCE_ONLINE or
INTERNET_AUTODIAL_FORCE_UNATTENDED, 0) then
begin
// error
result := false;
end;
end;

Verbindung wieder auflegen :

Procedure DisConnectWWW;
var
dwConnectionTypes: DWORD;
begin
dwConnectionTypes := INTERNET_CONNECTION_MODEM + INTERNET_CONNECTION_LAN +
INTERNET_CONNECTION_PROXY;
if InternetGetConnectedState(@dwConnectionTypes, 0) then
// connected
InternetAutodialHangup(0);
end;
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 12.11.02 12:28 
Hi
soweit ich weiss, kannst du das überhaupt nicht verhindern, solange in deinen Internetoptionen eingestellt ist, dass die Verbindung automatisch hergestellt werden soll.

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
DataCool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Di 12.11.02 12:34 
Es ging ja auch nicht darum irgentetwas zu verhindern, sondern um eine Verbindung herzustellen :shock:

Data
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 12.11.02 13:12 
@DataCool
Borlox hat folgendes geschrieben:

ich möchte die Internetverbindung prüfen und habe es versucht mit einem Ping auf eine andere Site zu prüfen, aber ich möchte wenn ich das prüfe nicht, dass er anwählt, wie kann ich das machen?

Wer lesen kann ist klar im Vorteil :mrgreen:

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
DataCool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Di 12.11.02 13:32 
:oops: :oops: :oops:

Asche auf mein Haupt :autsch:
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 12.11.02 13:38 
Hi!

Hier wurde das besprochen.

Cu,
Udontknow
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 12.11.02 13:39 
Oh... :oops: Die Katze beisst sich in den Schwanz...
LCS
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1305
Erhaltene Danke: 1

WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
BeitragVerfasst: Di 12.11.02 13:52 
Sind wir heute alle ein bisschen konfus? :mrgreen:
Ich gebs jetzt auch auf. Bei dem Wetter draussen: :wave:

Gruss Lothar

_________________
Der BH ist für die Brust, der Plan ist für'n Ar...
DataCool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Di 12.11.02 14:12 
Da ich die Frage jetzt ja verstanden haben :D

Hier die Antwort : 8)

Benutze einfach die NMHTTP Komponente :

function checkOnline : Boolean;
begin
try
NMHTTP.Get('www.auq.de');
Result := true;
except
Result := false;
end;
end;

So wird auf jeden Fall keine Verbindung hergestellt, sondern nur überprüft ob eine besteht !

Data
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 12.11.02 14:37 
Ja, aber da springt doch dann die automatische Verbindungsherstellung vom Betriebssystem auch an, oder irre ich?

Ist das etwa vielleicht die Lösung? LCS sagte es ja bereits: Borlox, du weisst, das du das automatische Verbinden in Windows deaktivieren kannst?

Cu,
Udontknow
DataCool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 112



BeitragVerfasst: Di 12.11.02 14:40 
Nein, dabei sollte die automatische Verbindung nicht anspringen !!!

8) 8) 8)
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 12.11.02 14:50 
Jo, hast recht!

Allerdings ist es natürlich ein wenig nervig, daß er dann
a) im Offline-Fall Exceptions rauswirft
b) Im Online-Fall den kompletten URL-Inhalt lädt.

Eigentlich sollte es dann ja ein Host-Lookup schon tun... Mal sehen...

*Grummel* Natürlich gibt´s keine Quellen zu FastNet-Komponenten. Ich hasse Komponenten ohne Quellen! :evil:

Cu,
Udontknow
Cashels
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 167



BeitragVerfasst: Di 12.11.02 17:55 
Kann man diesen try..except Block denn nicht mit einem Ping machen. Ich benutze das in einem Programm um zu kucken ob ein Update verfügbar ist. Dabei wird nie gefragt, ob ich eine Verbindungen aufbauen will...

Gruss,
tom