Declare Function InternetGetConnectedStateEx Lib "wininet.dll" Alias "InternetGetConnectedStateExA" (lpdwFlags As Long, lpszConnectionName As Long, dwNameLen As Long, ByVal dwReserved As Long) As Long
'Allocate buffer for the name of connection
strConnectionName = Space(256)
'Initialize variable lNameLen - the length of the buffer
lNameLen = 256
'Get the pointers to the variables we're going to pass
'to the function InternetGetConnectedStateEx
lPtr = StrPtr(strConnectionName)
lNameLenPtr = VarPtr(lNameLen)
'Call the InternetGetConnectedStateEx function.
'Please pay attention that two parameters are
'passing pass by the value (ByVal)
lRetVal = InternetGetConnectedStateEx(lConnectionFlags, _
ByVal lPtr, ByVal lNameLen, 0&)
'The processing of the lRetVal is missed
'Check the appropriate bits of the lConnectionFlags
'in order to initialize the properties of CWinInetConnection
mvarUseModem = lConnectionFlags And INTERNET_CONNECTION_MODEM
mvarUseLAN = lConnectionFlags And INTERNET_CONNECTION_LAN
mvarUseProxy = lConnectionFlags And INTERNET_CONNECTION_PROXY
mvarIsRasInstalled = lConnectionFlags And INTERNET_RAS_INSTALLED
mvarIsOffline = lConnectionFlags And INTERNET_CONNECTION_OFFLINE mvarIsConnectionConfigured = lConnectionFlags And _ INTERNET_CONNECTION_CONFIGURED
'Extract the name of current connection with the help
'of the pointer to the variable strConnectionName
mvarConnectionName = StringFromPointer(lPtr)
Just for information here is the function that extracts the string by the pointer.
Function StringFromPointer(ByVal lPointer As Long) As String
Dim strTemp As String
Dim lRetVal As Long
strTemp = String$(lstrlen(ByVal lPointer), 0)
lRetVal = lstrcpy(ByVal strTemp, ByVal lPointer)
If lRetVal Then StringFromPointer = strTemp
Declare Function InternetSetOption Lib "wininet.dll" Alias "InternetSetOptionA" (ByVal hInternet As Long, ByVal dwOption As Long, lpBuffer As Any, ByVal dwBufferLength As Long) As Long