#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    36
    Rep Power
    11

    Checking to see if your connected to the internet?


    Is their a simple way to check during run time if the user is connected to the internet or not?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Location
    Behind you
    Posts
    19
    Rep Power
    0
    and..how can I disconnect in 0,2 microsecond the connection?
    Or..better..start the connection..work work..close the connection.

    In this way the user will remain connected only usefull time and won't lose useless money (56 k connection, ovviusly)
  4. #3
  5. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    Yes, it's called InternetGetConnectedState(). See http://msdn.microsoft.com/library/en...asp?frame=true for more information.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    36
    Rep Power
    11
    What if you don't know anything about the users internet? Is their a way to, say, ping yahoo.com (if you get the response your internet is active, if you don't your offline)? Or is 'INTERNET_CONNECTION_CONFIGURED' an all purpose way of using it?
  8. #5
  9. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    Just check the return value of the function. If TRUE, then they're connected. If FALSE, they aren't. The lpdwFlags variable returns the type of connection.
    Last edited by Scorpions4ever; June 29th, 2004 at 02:45 PM.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    36
    Rep Power
    11
    But for lpdwFlags, I don't know what the people's configuration is like. They could be on dialup, have no internet, or broadband. Should I use 'INTERNET_CONNECTION_CONFIGURED' for an all purpose lpdwFlags?
  12. #7
  13. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    You don't pass a value to that function -- that's a variable that the function sets, to let you know what the type of connection is.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    36
    Rep Power
    11
    Ok, I tried this
    Code:
    procedure TForm1.FormCreate(Sender: TObject);
    var
    x: bool;
    begin
    x := InternetGetConnectedState(0,0);
    if x = FALSE then begin
    showmessage('false');
    end;
    if x = TRUE then begin
    showmessage('true');
    end;
    end;
    
    end.
    however even if I ipconfig /release (disconnect from internet) it still reports true. any ideas? Anyone know how to make ping yahoo (assuming thats always up) and if it gets a reply assume its online?
  16. #9
  17. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    This works for me:
    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    var
    	dwConnType : DWORD;
    begin
    	if (InternetGetConnectedState(@dwConnType, 0) = TRUE) then
    		ShowMessage('Connected')
    	else
    		ShowMessage('Not connected');
    end;
    I disabled my networking by going to my network connection properties and selecting Disable. Then it showed Not connected as expected. If you're looking for a ping component, then take a look at http://www.overbyte.be/ and check out the ICS component suite.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Location
    Behind you
    Posts
    19
    Rep Power
    0
    And to connect or disconnect?
    Which is the function?
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    36
    Rep Power
    11
    Well, unfortunately your code reports I am online even when I'm not so I guess I'll use this ping component . I don't really get how it works though, all I want it to do is ping yahoo.com and see if I get any reply at all. I don't really get how you get the reply/non reply with this component. And, this wouldn't be considered a DDOS attack if I have it ping it before it does something internet related right?
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    27
    Rep Power
    0
    Try pinging your own site if your worried about it being considered a DDOS attack, and have you figured out how to use the component? I'd be interested in using it for the same purpose.

IMN logo majestic logo threadwatch logo seochat tools logo