#pragma library( "ascom10.lib" ) #define FLAG_ICC_FORCE_CONNECTION 1 #define CLSID_NetworkListManager "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}" //////////// // FUNCTION HasInternetConnection_(aWhich) // Verifica se existe alguma conexão disponível com a internet, onde: // [@] -> array that will .t. or .f. indicating the existence of: // IND_CONNECTIVITY__IPV4_NOTRAFFIC // There is connectivity to a network, but the service // // cannot detect any IPv4 Network Traffic // IND_CONNECTIVITY__IPV6_NOTRAFFIC // There is connectivity to a network, but the service // // cannot detect any IPv6 Network Traffic // IND_CONNECTIVITY__IPV4_SUBNET // There is connectivity to the local subnet using the IPv4 protocol // IND_CONNECTIVITY__IPV4_LOCALNETWORK // There is connectivity to a routed network using the IPv4 protocol // IND_CONNECTIVITY__IPV4_INTERNET // There is connectivity to the Internet using the IPv4 protocol // IND_CONNECTIVITY__IPV6_SUBNET // There is connectivity to the local subnet using the IPv6 protocol // IND_CONNECTIVITY__IPV6_LOCALNETWORK // There is connectivity to a local network using the IPv6 protoco // IND_CONNECTIVITY__IPV6_INTERNET // There is connectivity to the Internet using the IPv6 protocol // Caso não haja conexões ativas conterá {} // // Vide https://msdn.microsoft.com/en-us/library/aa370773(v=vs.85).aspx // // Returns: .t. if it has any connection active // .f. if it has not any connection acitive; will be {} ///// LOCAL oListManager, nConnections, lOk oListManager := CreateObject(CLSID_NetworkListManager) if oListManager == NIL aWhich := {} lOk := .f. else nConnections := oListManager:getConnectivity() if nConnections == 0 aWhich := {} lOk := .f. else aWhich := {,,,,,,,} aWhich[IND_CONNECTIVITY__IPV4_NOTRAFFIC] := (BAnd(nConnections, NLM_CONNECTIVITY_IPV4_NOTRAFFIC) <> 0) aWhich[IND_CONNECTIVITY__IPV6_NOTRAFFIC] := (BAnd(nConnections, NLM_CONNECTIVITY_IPV6_NOTRAFFIC) <> 0) aWhich[IND_CONNECTIVITY__IPV4_SUBNET] := (BAnd(nConnections,NLM_CONNECTIVITY_IPV4_SUBNET) <> 0) aWhich[IND_CONNECTIVITY__IPV4_LOCALNETWORK] := (BAnd(nConnections,NLM_CONNECTIVITY_IPV4_LOCALNETWORK) <> 0) aWhich[IND_CONNECTIVITY__IPV4_INTERNET] := (BAnd(nConnections,NLM_CONNECTIVITY_IPV4_INTERNET) <> 0) aWhich[IND_CONNECTIVITY__IPV6_SUBNET] := (BAnd(nConnections,NLM_CONNECTIVITY_IPV6_SUBNET) <> 0) aWhich[IND_CONNECTIVITY__IPV6_LOCALNETWORK] := (BAnd(nConnections,NLM_CONNECTIVITY_IPV6_LOCALNETWORK) <> 0) aWhich[IND_CONNECTIVITY__IPV6_INTERNET] := (BAnd(nConnections,NLM_CONNECTIVITY_IPV6_INTERNET) <> 0) lOk := .t. endif endif RETURN lOk