c# - Windows and Detecting Captive Portals -
trying detect when captive portal in use on internet connection i.e laptop connected @ coffee shop.
trying achieve using network list manager com object:
networklist.networklistmanager _networklistmanager = new networklistmanager(); foreach (inetworkconnection net in _networklistmanager.getnetworkconnections()) { if (net.getconnectivity().hasflag(nlm_connectivity.nlm_connectivity_ipv4_internet) == true) { // check if connected captive web portal // using nlm_internet_connectivity_webhijack } }
according documentation here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa370750(v=vs.85).aspx
"these connectivity flags can retrieved querying na_internetconnectivityv4 or na_internetconnectivityv6 properties using ipropertybag interface inetwork or inetworkconnection interface"
i appears na_internetconnectivityv4 enumerations not present (incomplete implementation) or don't know how work them.
has used or have ideas on ways detect when captive portal in use?
this not c# found apis working on c++
pnetworklistmanager->getnetworks (nlm_enum_network_connected, &penum) inetwork *pinetwork;
//should loop through possible networks. hresult hr = penum->next(1, &pinetwork, nullptr); ipropertybag *pnetworkpropertybag; hresult hrqueryinterface = pinetwork->queryinterface(iid_ipropertybag, (lpvoid*)&pnetworkpropertybag); if (succeeded(hrqueryinterface 1) && pnetworkpropertybag != nullptr) { nlm_connectivity networkconnectivity; variant variantconnectivity; if (succeeded(pinetwork->getconnectivity(&networkconnectivity))) { if ((networkconnectivity & nlm_connectivity_ipv4_internet) == nlm_connectivity_ipv4_internet) { variantinit(&variantconnectivity); if (succeeded(pnetworkpropertybag->read(na_internetconnectivityv4, &variantconnectivity, nullptr)) && (v_uint(&variantconnectivity) & nlm_internet_connectivity_webhijack) == nlm_internet_connectivity_webhijack) { //captive portal detected } variantclear(&variantconnectivity); } }
check full details: http://www.codeproject.com/articles/1088221/captive-portal-detection-with-windows-apis
Comments
Post a Comment