Bonjour

Voulant intégrer à une application C++ Builder un appel à un WebService qui interroge une base de données OVH MySQL, je vérifie au préalable la présence d'une connexion au réseau LAN qui détermine l'accès à internet (sans le garantir). Pour cela j'exploite la fonction InternetGetConnectedState de Wininet.dll.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
short __fastcall IsConnectedToInternet(DWORD * dwConnectionTypes )
{
typedef BOOL (WINAPI *PF_INETGETCONNECTEDSTATE)(LPDWORD, DWORD);
HANDLE hWinInet=NULL;
 
hWinInet = LoadLibrary("WININET.DLL");  //Chargement de la dll
 
PF_INETGETCONNECTEDSTATE pfInternetGetConnectedState;
if(hWinInet == NULL)
        return -1;
 
pfInternetGetConnectedState = (PF_INETGETCONNECTEDSTATE) GetProcAddress(
                          hWinInet, "InternetGetConnectedState");
 
if(pfInternetGetConnectedState == NULL)
        return -2;
 
return (pfInternetGetConnectedState(dwConnectionTypes, 0))?1:-1;
 
}
cette fonction renvoie un DWORD comportant 7 flags

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
#define INTERNET_CONNECTION_MODEM           0x01
#define INTERNET_CONNECTION_LAN             0x02
#define INTERNET_CONNECTION_PROXY           0x04
#define INTERNET_CONNECTION_MODEM_BUSY      0x08  /* no longer used */
#define INTERNET_RAS_INSTALLED              0x10
#define INTERNET_CONNECTION_OFFLINE         0x20
#define INTERNET_CONNECTION_CONFIGURED      0x40
La présence du flag INTERNET_CONNECTION_LAN indique une connection au réseau LAN.
Existe t il des configurations où ce n'est pas ce flag qui indique la présence d'une connection ? Notamment INTERNET_CONNECTION_PROXY ?
La présence du flag INTERNET_CONNECTION_PROXY suffit elle à établir la présence d'une connexion réseau ?
Question subsidiaire : RAS_INSTALLED accompagne toujours CONNECTION_LAN. Que signifie précisément RAS ?
Merci