I misunderstood with windows C interopt :disappoin...
# kotlin-native
a
I misunderstood with windows C interopt 😞 C code:
Copy code
PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
WlanEnumInterfaces(hClient, NULL, &pIfList);
for (i = 0; i < (int) pIfList->dwNumberOfItems; i++) {
    PWLAN_INTERFACE_INFO pIfInfo = (WLAN_INTERFACE_INFO *) &pIfList->InterfaceInfo[i];
How can I convert this code to kotlin?
Copy code
memScoped {
    val zeroValue: CValue<PWLAN_INTERFACE_INFO_LISTVar> = zeroValue()
    val ppInterfaceList: CPointer<CPointerVarOf<CPointer<_WLAN_INTERFACE_INFO_LIST>>> = zeroValue.getPointer(memScope)
    WlanEnumInterfaces(wlanHandle, null, ppInterfaceList)
    val pInterfaceList: CPointerVarOf<PWLAN_INTERFACE_INFO_LIST> = ppInterfaceList.pointed
    val interfaceList: PWLAN_INTERFACE_INFO_LIST? = pInterfaceList.value
    val wlanIfsInfoList: _WLAN_INTERFACE_INFO_LIST? = interfaceList?.pointed
    for (pIfInfo ????????)
}
Fixed:
Copy code
wlanIfsInfoList?.let {
    val dwNumberOfItems = wlanIfsInfoList.memberAt<IntVar>(0).value
    val dwIndex = wlanIfsInfoList.memberAt<IntVar>(4).value
    for (i in dwIndex until dwNumberOfItems) {
        val wlanIfsInfo: _WLAN_INTERFACE_INFO = 
                wlanIfsInfoList.memberAt(8)
    }
}