check ob Online?





  • Jetzt haut's dank eurer Hilfe hin.

    #include "Wininet.h"
    #pragma comment(lib,"wininet")
    
    bool CmyDialog::CheckForConnection()
    {
       BOOL isOnline = false;
    
       if (InternetCheckConnection("http://www.google.de",FLAG_ICC_FORCE_CONNECTION,0))
       {
          isOnline = true;
       } 
          return(isOnline);
    }
    

    Gruß Matten



  • Hi,

    ich weiß das Thema iss eigentlich schon beendet, aber ich wollt einfach noch kurz die kürzeste Version vorstellen 🙂

    #include "Wininet.h" 
    #pragma comment(lib,"wininet") 
    
    bool CmyDialog::CheckForConnection() 
    { 
       return InternetGetConnectedState(NULL,NULL);
    }
    

    mfg



  • Der Quellcode müsste auch funktionieren...

    http://mitglied.lycos.de/Devil_81/CPP/online.htm

    Devil



  • Den Code hatte ich auch probiert! bekomme aber immer '0' zurück!

    Trotzdem Danke an alle.



  • der Beitrag hier ist zwar schon sehr alt, aber ich wollte das auch mal probieren. Ich benutze jetzt Visual C++ .Net.. ich habe den Code so kopiert :

    #include "Wininet.h"
    #pragma comment(lib,"wininet")
    
    bool CmyDialog::CheckForConnection()
    {
       return InternetGetConnectedState(NULL,NULL);
    }
    

    und bekomme dann eine unmenge an Fehlermeldungen:

    ------ Build started: Project: inet_test, Configuration: Debug Win32 ------

    Compiling...
    inet_test.cpp
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(56) : error C2146: syntax error : missing ';' before identifier 'HINTERNET'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(56) : error C2501: 'HINTERNET' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(57) : error C2143: syntax error : missing ';' before ''
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(57) : error C2378: 'HINTERNET' : redefinition; symbol cannot be overloaded with a typedef
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(56) : see declaration of 'HINTERNET'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(57) : error C2501: 'LPHINTERNET' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(59) : error C2146: syntax error : missing ';' before identifier 'INTERNET_PORT'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(59) : error C2501: 'INTERNET_PORT' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(60) : error C2143: syntax error : missing ';' before '
    '
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(60) : error C2378: 'INTERNET_PORT' : redefinition; symbol cannot be overloaded with a typedef
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(59) : see declaration of 'INTERNET_PORT'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(60) : error C2501: 'LPINTERNET_PORT' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(297) : error C2146: syntax error : missing ';' before identifier 'dwResult'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(297) : error C2501: '__unnamed::DWORD_PTR' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(297) : error C2501: '__unnamed::dwResult' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(303) : error C2146: syntax error : missing ';' before identifier 'dwError'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(303) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(303) : error C2501: '__unnamed::dwError' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(312) : error C2146: syntax error : missing ';' before identifier 'Socket'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(312) : error C2501: '__unnamed::DWORD_PTR' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(312) : error C2501: '__unnamed::Socket' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(313) : error C2146: syntax error : missing ';' before identifier 'SourcePort'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(313) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(313) : error C2501: '__unnamed::SourcePort' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(314) : error C2146: syntax error : missing ';' before identifier 'DestPort'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(314) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(314) : error C2501: '__unnamed::DestPort' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(315) : error C2146: syntax error : missing ';' before identifier 'Flags'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(315) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(315) : error C2501: '__unnamed::Flags' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(339) : error C2146: syntax error : missing ';' before identifier 'dwAccessType'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(339) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(339) : error C2501: '__unnamed::dwAccessType' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(345) : error C2146: syntax error : missing ';' before identifier 'lpszProxy'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(345) : error C2501: '__unnamed::LPCTSTR' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(345) : error C2501: '__unnamed::lpszProxy' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(351) : error C2146: syntax error : missing ';' before identifier 'lpszProxyBypass'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(351) : error C2501: '__unnamed::LPCTSTR' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(351) : error C2501: '__unnamed::lpszProxyBypass' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(363) : error C2146: syntax error : missing ';' before identifier 'dwOption'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(363) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(363) : error C2501: '__unnamed::dwOption' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(365) : error C2146: syntax error : missing ';' before identifier 'dwValue'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(365) : error C2501: '__unnamed::__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(365) : error C2501: '__unnamed::__unnamed::dwValue' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(366) : error C2146: syntax error : missing ';' before identifier 'pszValue'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(366) : error C2501: '__unnamed::__unnamed::LPSTR' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(366) : error C2501: '__unnamed::__unnamed::pszValue' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(367) : error C2146: syntax error : missing ';' before identifier 'ftValue'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(367) : error C2501: '__unnamed::__unnamed::FILETIME' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(367) : error C2501: '__unnamed::__unnamed::ftValue' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(371) : error C2146: syntax error : missing ';' before identifier 'dwOption'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(371) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(371) : error C2501: '__unnamed::dwOption' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(373) : error C2146: syntax error : missing ';' before identifier 'dwValue'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(373) : error C2501: '__unnamed::__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(373) : error C2501: '__unnamed::__unnamed::dwValue' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(374) : error C2146: syntax error : missing ';' before identifier 'pszValue'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(374) : error C2501: '__unnamed::__unnamed::LPWSTR' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(374) : error C2501: '__unnamed::__unnamed::pszValue' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(375) : error C2146: syntax error : missing ';' before identifier 'ftValue'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(375) : error C2501: '__unnamed::__unnamed::FILETIME' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(375) : error C2501: '__unnamed::__unnamed::ftValue' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(387) : error C2146: syntax error : missing ';' before identifier 'dwSize'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(387) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(387) : error C2501: '__unnamed::dwSize' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(388) : error C2146: syntax error : missing ';' before identifier 'pszConnection'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(388) : error C2501: '__unnamed::LPSTR' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(388) : error C2501: '__unnamed::pszConnection' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(389) : error C2146: syntax error : missing ';' before identifier 'dwOptionCount'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(389) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(389) : error C2501: '__unnamed::dwOptionCount' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(390) : error C2146: syntax error : missing ';' before identifier 'dwOptionError'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(390) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(390) : error C2501: '__unnamed::dwOptionError' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(395) : error C2146: syntax error : missing ';' before identifier 'dwSize'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(395) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(395) : error C2501: '__unnamed::dwSize' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(396) : error C2146: syntax error : missing ';' before identifier 'pszConnection'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(396) : error C2501: '__unnamed::LPWSTR' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(396) : error C2501: '__unnamed::pszConnection' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(397) : error C2146: syntax error : missing ';' before identifier 'dwOptionCount'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(397) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(397) : error C2501: '__unnamed::dwOptionCount' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(398) : error C2146: syntax error : missing ';' before identifier 'dwOptionError'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(398) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(398) : error C2501: '__unnamed::dwOptionError' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(448) : error C2146: syntax error : missing ';' before identifier 'dwMajorVersion'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(448) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(448) : error C2501: '__unnamed::dwMajorVersion' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(449) : error C2146: syntax error : missing ';' before identifier 'dwMinorVersion'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(449) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(449) : error C2501: '__unnamed::dwMinorVersion' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(457) : error C2146: syntax error : missing ';' before identifier 'dwMajorVersion'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(457) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(457) : error C2501: '__unnamed::dwMajorVersion' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(458) : error C2146: syntax error : missing ';' before identifier 'dwMinorVersion'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(458) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(458) : error C2501: '__unnamed::dwMinorVersion' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(472) : error C2146: syntax error : missing ';' before identifier 'dwConnectedState'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(472) : error C2501: '__unnamed::DWORD' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(472) : error C2501: '__unnamed::dwConnectedState' : missing storage-class or type specifiers
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(479) : error C2146: syntax error : missing ';' before identifier 'dwFlags'
    c:\Programme\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinInet.h(479) : fatal error C1003: error count exceeds 100; stopping compilation

    Build log was saved at "file://d:\Visual Studio Projects\inet_test\Debug\BuildLog.htm"
    inet_test - 102 error(s), 0 warning(s)

    das asgt mir alles garnichts und der Fehler scheint ja auch in der wininet.h zu liegen...

    danke



  • Such mal in der MSDN nach den Fehlernummern...



  • Das gleiche Problem hatte ich auch wie Dahein!
    Mir ist aufgefallen das dieses Problem erst nach einem SDK-Update
    entstanden ist...

    Lösung ?



  • das hört sich schlecht an... 😞



  • wie mache ich das denn dann? wenn ich das oben richtig gesehen ahbe berughen die anderen Lösungen auch auf der wininet.h


Anmelden zum Antworten