CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2003
    Posts
    7

    Check the internet connection state

    Hello,

    I would like to be able to detect if the computer is connected to Internet. I've tried InternetGetConnectedState() from wininet, but I always get TRUE, nethertheless I'm connected or not.

    I would like my application to check pop3 accounts, but if the computer is not connected, there is a hang (big timeout when trying to connect).

    Thanks.

  2. #2
    Join Date
    May 2002
    Location
    Somewhere over the rainbow
    Posts
    423
    check this source:
    http://spiff.tripnet.se/~iczelion/files/Welcome2Net.zip

    its i Win32Asm, but there isn't much diff, actually they are the same, just diff syntax!
    have fun translating
    Bengi

  3. #3
    Join Date
    Jan 2003
    Posts
    7
    Thanks, dont worry I've got no pb with asm and it's the same API.

  4. #4
    Join Date
    Aug 2002
    Location
    United States
    Posts
    729
    to translate......(even though i'm sure you can do it)

    WSADATA wsadata;
    WSAStartup(0x101, &wsadata);
    if(gethostbyname("www.microsoft.com") != NULL)
    We_are_online();
    else
    Offline();
    WSACleanup();


    this is one method but also you might want to try using
    gethostname();
    and then gethostbyname(); with information returned from the first one. then you can enumerate the IP list returned and check against common local ips *127.0.0.1 or home network ones*

  5. #5
    Join Date
    Mar 2002
    Posts
    350
    BOOL InetIsOffline(
    DWORD dwFlags,
    );

    or

    DWORD RasEnumConnections(
    LPRASCONN lprasconn, // buffer to receive connections data
    LPDWORD lpcb, // size in bytes of buffer
    LPDWORD lpcConnections // number of connections written to buffer
    );

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured