CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 1999
    Posts
    60

    How to detect when we connect to internet

    I want notification to my s/w when connected to internet


  2. #2
    Join Date
    Jun 1999
    Posts
    2

    Re: How to detect when we connect to internet

    Use

    BOOL InternetCheckConnection(
    IN LPCSTR lpszUrl,
    IN DWORD dwFlags,
    IN DWORD dwReserved
    );
    with lpszUrl as NULL

    HTH
    Ghazi


    [email protected]
    Dundas Software


  3. #3
    Join Date
    May 1999
    Location
    nz
    Posts
    96

    Re: How to detect when we connect to internet

    I've been using this successfully


    DWORD lpdwFlags ;//= INTERNET_CONNECTION_MODEM|INTERNET_CONNECTION_LAN|INTERNET_CONNECTION_PROXY ;
    if( InternetGetConnectedState(&lpdwFlags ,0) == TRUE){ ....}





    maybe - InternetCheckConnection works as well, but I thought it checked to see if you could connect.. Oh well

    Regards
    Colin Davies

    At the Mount

  4. #4
    Join Date
    May 1999
    Location
    Switzerland
    Posts
    58

    Re: How to detect when we connect to internet

    Hi,
    I had once the same problem. Here the code to get the connections open to the net.
    If the enumeration returns NOT 0, there is no connection. Else you can even see which ones are open.


    RASCONN ras[20];
    DWORD dSize,dNumber,dCount;

    ras[0].dwSize = sizeof(RASCONN);
    dSize = sizeof( ras ); // Get active RAS - Connection

    if( RasEnumConnections( ras, &dSize, &dNumber ) == 0 )
    {
    for( dCount = 0; dCount < dNumber; dCount++ )
    {
    do something
    }
    }




    Have fun
    Dan


    Dan
    --------------------------------------
    It's always nice to see, whether the hints work. I appreciate feedback

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