AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi Prüfen ob Pc online
Thema durchsuchen
Ansicht
Themen-Optionen

Prüfen ob Pc online

Ein Thema von simonko · begonnen am 21. Okt 2005 · letzter Beitrag vom 14. Nov 2007
Antwort Antwort
Seite 1 von 3  1 23      
simonko

Registriert seit: 2. Jun 2005
125 Beiträge
 
#1

Prüfen ob Pc online

  Alt 21. Okt 2005, 13:24
Wie kann ich prüfen ob eine Verbindung zur Zeit zum internet besteht oder nicht?
  Mit Zitat antworten Zitat
Benutzerbild von DataCool
DataCool

Registriert seit: 10. Feb 2003
Ort: Lingen
909 Beiträge
 
Delphi 10.3 Rio
 
#2

Re: Prüfen ob Pc online

  Alt 21. Okt 2005, 13:30
Hi,

da gibt es so viele Möglichkeiten

- Versuch eine IP im Netz zu pingen, bekommst Du ne Antwort bist du online.

- Versuch mit Indys TIdHttp eine URL zu erreichen, bekommst Du eine Antwort bist Du online.

.....

Als Ansatz sollte das allemal reichen oder ?

Gruß Data
Der Horizont vieler Menschen ist ein Kreis mit Radius Null, und das nennen sie ihren Standpunkt.
  Mit Zitat antworten Zitat
Benutzerbild von RavenIV
RavenIV

Registriert seit: 12. Jan 2005
Ort: Waldshut-Tiengen
2.875 Beiträge
 
Delphi 2007 Enterprise
 
#3

Re: Prüfen ob Pc online

  Alt 21. Okt 2005, 13:30
das einfachste:
such dir einen verlässlichen Server (z.B. www.arcor.de) und mach einen ping auf diesen server.
Wenn der ping OK ist, dann haste Verbindung...
Klaus E.
Linux - das längste Text-Adventure aller Zeiten...
Wer nie Linux mit dem vi konfiguriert hat, der hat am Leben vorbei geklickt.
  Mit Zitat antworten Zitat
Benutzerbild von TeronG
TeronG

Registriert seit: 19. Jul 2004
Ort: München
960 Beiträge
 
Delphi 2007 Professional
 
#4

Re: Prüfen ob Pc online

  Alt 21. Okt 2005, 13:33
Zitat von DataCool:
- Versuch eine IP im Netz zu pingen, bekommst Du ne Antwort bist du online.
LOOOL .. sobald ich ne IP außerhalb meines Netzwerkes anpinge wähle ich mich auch schon in's netz ein...

Zitat:
da gibt es so viele Möglichkeiten
Für deinen eigenen Rechner mag es eine Möglichkeit geben .. aber KEINE, die allgemeingültig ist.
龍 Der Unterschied zwischen Theorie und Praxis ist in der Praxis größer als in der Theorie.
  Mit Zitat antworten Zitat
Benutzerbild von Chegga
Chegga

Registriert seit: 5. Nov 2004
Ort: Kirchheim
453 Beiträge
 
Delphi 7 Architect
 
#5

Re: Prüfen ob Pc online

  Alt 21. Okt 2005, 13:33
Hi,

durch die DP-Suche hättest du diesen Beitrag gefunden:
OnlineStatus
...lesen...

MfG Marc
Marc P.
Grüße aus Kirchheim Teck
  Mit Zitat antworten Zitat
simonko

Registriert seit: 2. Jun 2005
125 Beiträge
 
#6

Re: Prüfen ob Pc online

  Alt 21. Okt 2005, 13:37
Ich möcht ein programm schreiben dass mir die internetstunden zählt die ich online bin, weil
ich hab nur 200 freistunden. mit einem timer jede sekunde www.arcord.de pingen klingt irgendwie
blöd oder?
  Mit Zitat antworten Zitat
Benutzerbild von TeronG
TeronG

Registriert seit: 19. Jul 2004
Ort: München
960 Beiträge
 
Delphi 2007 Professional
 
#7

Re: Prüfen ob Pc online

  Alt 21. Okt 2005, 13:38
so ... endlich gefunden
klick (@Daniel: das ding find ich Spitze )

Wenn du nen Router hast kannste das mit dem PINGEN eh vergessen, weil der bei jedem ping einwählen würde allerdings kannse der Router evtl. befragen ob er online ist ... aber zu dem Thema steht in der DP schon genug
龍 Der Unterschied zwischen Theorie und Praxis ist in der Praxis größer als in der Theorie.
  Mit Zitat antworten Zitat
Benutzerbild von DataCool
DataCool

Registriert seit: 10. Feb 2003
Ort: Lingen
909 Beiträge
 
Delphi 10.3 Rio
 
#8

Re: Prüfen ob Pc online

  Alt 21. Okt 2005, 13:39
Hi,

eine allgemein gültige Methode gibt es nicht.
Wird ja auch in dem Link den Chegga gepostet hat deutlich.

Eigentlich kann man nur mit meheren kombinierten Methoden zum Ziel kommen.

- Prüfen, ob Netzwerkkabel angeschlossen ist
- Wenn ja dann ne URL zur Sicherheit pingen

Gruß Data
Der Horizont vieler Menschen ist ein Kreis mit Radius Null, und das nennen sie ihren Standpunkt.
  Mit Zitat antworten Zitat
Benutzerbild von TeronG
TeronG

Registriert seit: 19. Jul 2004
Ort: München
960 Beiträge
 
Delphi 2007 Professional
 
#9

Re: Prüfen ob Pc online

  Alt 21. Okt 2005, 13:42
Zitat von DataCool:
- Prüfen, ob Netzwerkkabel angeschlossen ist
und was wennich n Modem und daher KEIN Netzwerkkabel hab?
Zitat:
- Wenn ja dann ne URL zur Sicherheit pingen
Router .... (mehr sog i ned) ^^

PS: auf link s.o. verweis ... bitte durchlesen ^^
龍 Der Unterschied zwischen Theorie und Praxis ist in der Praxis größer als in der Theorie.
  Mit Zitat antworten Zitat
Benutzerbild von DataCool
DataCool

Registriert seit: 10. Feb 2003
Ort: Lingen
909 Beiträge
 
Delphi 10.3 Rio
 
#10

Re: Prüfen ob Pc online

  Alt 21. Okt 2005, 13:53
Hi,

noch ne Methode, aber gleich vorweg um TeronG ruhig zu stellen
Eine definitiv sichere Methode gibt es nicht :

Delphi-Quellcode:
{*************************************************************}
{            INetDetector Component for Delphi 32             }
{ Version:   2.1                                              }
{ E-Mail:    [email]info@utilmind.com[/email]                                }
{ Home Page: [url]http://www.utilmind.com[/url]                          }
{ Created:   November 5, 1999                                 }
{ Modified:  November 12, 1999                                }
{ Legal:     Copyright (c) 1999, UtilMind Solutions           }
{*************************************************************}
{ This component determines online status of the computer     }
{ (Connected or Disconnected).                                }
{*************************************************************}
{ PROPERTIES:                                                 }
{   Online: Boolean - Online status of local machine          }
{   DispatchInterval - Determines in milliseconds the         }
{                      intervals of time between checking     }
{                      online of a mode of the computer       }
{   Enabled: Boolean - As usual... =) If True then often      }
{                      queries for Internet Connection        }
{ EVENTS:                                                     }
{   OnChanged - causes if online status changed.              }
{*************************************************************}
{ Please see demo program for more information.               }
{*************************************************************}
{                     IMPORTANT NOTE:                         }
{ This software is provided 'as-is', without any express or   }
{ implied warranty. In no event will the author be held       }
{ liable for any damages arising from the use of this         }
{ software.                                                   }
{ Permission is granted to anyone to use this software for    }
{ any purpose, including commercial applications, and to      }
{ alter it and redistribute it freely, subject to the         }
{ following restrictions:                                     }
{ 1. The origin of this software must not be misrepresented,  }
{    you must not claim that you wrote the original software. }
{    If you use this software in a product, an acknowledgment }
{    in the product documentation would be appreciated but is }
{    not required.                                            }
{ 2. Altered source versions must be plainly marked as such,  }
{    and must not be misrepresented as being the original     }
{    software.                                                }
{ 3. This notice may not be removed or altered from any       }
{    source distribution.                                     }
{*************************************************************}

{*************************************************************}
{            --------------------------------------           }
{ Version:   2.1D                                             }
{ Modified:  R.L. Miller                                      }
{ E-Mail:    [email]74471.3622@compuserve.com[/email]                        }
{ Modified:  December 13, 1999                                }
{ Legal:     Added several r/o properties for diagnostics     }
{*************************************************************}
{ NEW PROPERTIES:                                             }
{  CurrentIP : String (R/O runtime only).Allows me to monitor }
{              what's going on inside IsIPPresent local func  }
{              inside WndProc().                              }
{  pCurrHostEnt : PHostEnt (R/O runtime only).  Same reason   }
{*************************************************************}


unit INetDetector;

interface

uses
  Windows, Messages, Classes, Forms, Winsock;

type
  TINetDetector = class(TComponent)
  private
    FEnabled: Boolean;
    FDispatchInterval: Cardinal;
    FWindowHandle: hWnd;
    FOnline: Boolean;
    FOnChanged: TNotifyEvent;

    FCurrentIP : String; {<--RLM Diagnostics}
    FpCurrHostEnt : PHostEnt; {<--RLM Diagnostics}

    procedure UpdateTimer;
    procedure SetEnabled(Value: Boolean);
    procedure SetDispatchInterval(Value: Cardinal);
    procedure SetNoneBool(Value: Boolean);
    procedure WndProc(var Msg: TMessage);
  protected
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    property CurrentIP : String read FCurrentIP; {<--RLM Diagnostics}
    property pCurrHostEnt : PHostEnt read FpCurrHostEnt; {<--RLM Diagnostics}

  published
    property Enabled: Boolean read FEnabled write SetEnabled;
    property DispatchInterval: Cardinal read FDispatchInterval write SetDispatchInterval;
    property Online: Boolean read FOnline write SetNoneBool;
    property OnChanged: TNotifyEvent read FOnChanged write FOnChanged;
  end;

procedure Register;

implementation

{$R *.dcr}

constructor TINetDetector.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FEnabled := True;
  FDispatchInterval := 1000;
  FWindowHandle := AllocateHWnd(WndProc);
  UpdateTimer;
end;

destructor TINetDetector.Destroy;
begin
  FEnabled := False;
  UpdateTimer;
  DeallocateHWnd(FWindowHandle);
  inherited Destroy;
end;

procedure TINetDetector.WndProc(var Msg: TMessage);
var
  OldState: Boolean;
  Key: hKey;
  PC: Array[0..4] of Char;
  Size: Integer;
  RegSays : Boolean; {<-- RLM 12/13/99}

  function IsIPPresent: Boolean;
  type
    TaPInAddr = Array[0..10] of PInAddr;
    PaPInAddr = ^TaPInAddr;
  var
    phe: PHostEnt;
    pptr: PaPInAddr;
    Buffer: Array[0..63] of Char;
    I: Integer;
    GInitData: TWSAData;
    IP: String;
  begin
    WSAStartup($101, GInitData);
    Result := False;
    GetHostName(Buffer, SizeOf(Buffer));
    phe := GetHostByName(buffer);
    FpCurrHostEnt := phe;
    if phe = nil then Exit;
    pPtr := PaPInAddr(phe^.h_addr_list);
    I := 0;
    while pPtr^[I] <> nil do
     begin
      IP := inet_ntoa(pptr^[I]^);
      Inc(I);
     end;
    FCurrentIP := IP;
    WSACleanup;
    Result := (IP <> '') and (IP <> '127.0.0.1');
  end;

  procedure FixOnlineState;
  begin
    if (not OldState and FOnline) or
       (OldState and not FOnline) then
       if Assigned(FOnChanged) then
        FOnChanged(Self);
  end;

begin
  with Msg do
   if Msg = wm_Timer then
    try
     OldState := FOnline;
     FOnline := IsIPPresent;
     FixOnlineState;

     if RegOpenKey(HKEY_LOCAL_MACHINE, 'System\CurrentControlSet\Services\RemoteAccess', Key) = ERROR_SUCCESS then
      begin
       Size := 4;
       if RegQueryValueEx(Key, 'Remote Connection', nil, nil, @PC, @Size) = ERROR_SUCCESS then
        begin
         {Original}
         {
        FOnline := PC[0] = #1;
        FixOnlineState;
         }

         {Changed 12/13/99 RLM -- AOL leaves PC bytes all 00's}
         RegSays := PC[0] = #1;
         FOnLine := FOnLine or RegSays;
         FixOnlineState;
        end
       else
        begin
         FOnline := IsIPPresent;
         FixOnlineState;
        end;
       RegCloseKey(Key);
      end
     else
      begin
       FOnline := IsIPPresent;
       FixOnlineState;
      end;
    except
     Application.HandleException(Self);
    end
   else
    Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
end;

procedure TINetDetector.UpdateTimer;
begin
  KillTimer(FWindowHandle, 1);
  if (FDispatchInterval <> 0) and FEnabled then
   SetTimer(FWindowHandle, 1, FDispatchInterval, nil);
end;

procedure TINetDetector.SetEnabled(Value: Boolean);
begin
  if Value <> FEnabled then
   begin
    FEnabled := Value;
    UpdateTimer;
   end;
end;

procedure TINetDetector.SetDispatchInterval(Value: Cardinal);
begin
  if Value <> FDispatchInterval then
   begin
    FDispatchInterval := Value;
    UpdateTimer;
   end;
end;

procedure TINetDetector.SetNoneBool(Value: Boolean); begin {} end;

procedure Register;
begin
  RegisterComponents('Standard', [TINetDetector]);
end;

end.
Der Horizont vieler Menschen ist ein Kreis mit Radius Null, und das nennen sie ihren Standpunkt.
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 3  1 23      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:34 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz