Thread: InternetGetConnectedState() help !

  1. #1
    Registered User
    Join Date
    Jun 2017
    Posts
    9

    InternetGetConnectedState() help !

    Hello there
    I am trying to get the internet status info with InternetGetConnectedState() but its not working. Take a look at my code...

    Code:
    #include <iostream>#include <wininet.h>
    using namespace std;
    int main()
    {
        BOOL result;
        DWORD check;
        result = InternetGetConnectedState(&check,0);
        if(result)
        {
            cout<<"Internet status is : TRUE";
        }
        else
        {
            cout<<"No Internet Connection";
        }
        return 0;
    }
    When I am trying to compile and run its showing below error :
    C:\[my_path]\main.o:main.cpp|| undefined reference to `InternetGetConnectedState@8'|
    I am using codeblocks and GCC compiler.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,706
    InternetGetConnectedState function (Windows)
    Scroll down to "Requirements"
    You have to tell your linker to use Wininet.lib/Wininet.dll

    It's something like project->settings->linker->additional libraries.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2017
    Posts
    9
    Quote Originally Posted by Salem View Post
    InternetGetConnectedState function (Windows)
    Scroll down to "Requirements"
    You have to tell your linker to use Wininet.lib/Wininet.dll

    It's something like project->settings->linker->additional libraries.
    I thought I have mistakes in my code .......but its working now.... Thank you very much bro.

Popular pages Recent additions subscribe to a feed

Tags for this Thread