1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to check internet connection

Discussion in 'MFC' started by Hystrio, Sep 15, 2006.

  1. Hystrio

    Hystrio New Member

    Joined:
    Sep 15, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi all!

    I am not a very smart programmer (just for hobby) so bear with me!

    I have written a small program with MFC to log my internet connections (date and times which are written into a file). Tha fact is that I have to open and close it manually, after I open and close the connection. What I would like to do is this:

    after I lauch the program, it should monitor possible connections, so that as soon as I connect with Internet it checks the time and when I close the connection it stops it.

    Are there functions to do this?

    Thank you all in advance

    Orlando
     
  2. e_pech

    e_pech New Member

    Joined:
    Jul 25, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    #include <Wininet.h>
    #pragma comment(lib,"wininet.lib")

    if (InternetGetConnectedState(INTERNET_CONNECTION_LAN | INTERNET_CONNECTION_MODEM,0) == FALSE)
    {
    // Don't attempt connection or it will bring up the dialog
    }


    I've tried it before, it works fine!

    http://www.experts-exchange.com/Programming/Languages/CPP/Q_23262600.html

    on that link, you'll have to scroll all the way down to see the answer!
     

Share This Page