Haruyuki Mohri

毛利春幸のブログです。

Android How to get current ipaddress, submask and gateway. C++Builder

Original information site.

Embarcadero Discussion Forums: Delphi XE5 - JWiFiManager Interface ...
stackoverflow.com

The source of stackoverflow.com, as it is hpp file conversion.

Opening the option setting of the project.

Status access Wi-Fi, a true. f:id:mojeld:20160216131541j:plain

Code

#include <Androidapi.JNI.JavaTypes.hpp>
#include <Androidapi.JNI.GraphicsContentViewText.hpp>
#include <Androidapi.Helpers.hpp>
#include "uJWiFi.hpp"
inline String __fastcall getIPInfo_(_di_JObject lobj)
{
    _di_ILocalObject lj0 = static_cast<_di_ILocalObject>(lobj);
    Ujwifi::_di_JWifiManager WifiManager = Ujwifi::TJWifiManager::Wrap(lj0->GetObjectID());
    Ujwifi::_di_JDhcpInfo DhcpInfo = WifiManager->getDhcpInfo();

    return JStringToString(DhcpInfo->toString());
};

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    _di_JObject WifiManagerObj = SharedActivityContext()->getSystemService(TJContext::JavaClass->WIFI_SERVICE);
    Memo1->Lines->CommaText = getIPInfo_(WifiManagerObj);
//
}

f:id:mojeld:20160216134815j:plain