Native Wifi Api C ++。关闭/开启wifi

时间:2016-01-14 14:19:10

标签: c++ visual-c++

我想在C ++ NativeWifi上为开/关wifi模块编写程序。 我收到了所有模块。然后我不知道该怎么办。我没有NativeWifi Api的经验。请帮助我,谢谢。

HANDLE hClient = NULL;
DWORD dwMaxClient = 2;      //    
DWORD dwCurVersion = 0;
DWORD dwResult = 0;
DWORD dwRetVal = 0;
int iRet = 0;

WCHAR GuidString[39] = { 0 };

unsigned int i, j, k;

/* variables used for WlanEnumInterfaces  */

PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
PWLAN_INTERFACE_INFO pIfInfo = NULL;

PWLAN_AVAILABLE_NETWORK_LIST pBssList = NULL;
PWLAN_AVAILABLE_NETWORK pBssEntry = NULL;

dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
if (dwResult != ERROR_SUCCESS) {
    wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult);
    return 1;
    // You can use FormatMessage here to find out why the function failed
}

dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList);
if (dwResult != ERROR_SUCCESS) {
    wprintf(L"WlanEnumInterfaces failed with error: %u\n", dwResult);
    return 1;
    // You can use FormatMessage here to find out why the function failed
}
else {
    wprintf(L"Num Entries: %lu\n", pIfList->dwNumberOfItems);
    wprintf(L"Current Index: %lu\n", pIfList->dwIndex);
    for (i = 0; i < (int)pIfList->dwNumberOfItems; i++) {
        pIfInfo = (WLAN_INTERFACE_INFO *)&pIfList->InterfaceInfo[i];
        wprintf(L"  Interface Index[%u]:\t %lu\n", i, i);
        iRet = StringFromGUID2(pIfInfo->InterfaceGuid, (LPOLESTR)&GuidString,
            sizeof(GuidString) / sizeof(*GuidString));
        // For c rather than C++ source code, the above line needs to be
        // iRet = StringFromGUID2(&pIfInfo->InterfaceGuid, (LPOLESTR) &GuidString, 
        //     sizeof(GuidString)/sizeof(*GuidString)); 
        if (iRet == 0)
            wprintf(L"StringFromGUID2 failed\n");
        else {
            wprintf(L"  InterfaceGUID[%d]: %ws\n", i, GuidString);
        }


    }

}

我收到了所有模块。接下来,如果WLAN_PHY_RADIO_STATE结构的dot11SoftwareRadioState或dot11HardwareRadioState成员是dot11_radio_state_off,则PHY的无线状态将关闭。

1 个答案:

答案 0 :(得分:0)

作为WLAN_PHY_RADIO_STATE州的文档,您可以使用<?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:openDrawer="start"> <include layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" /> <android.support.design.widget.NavigationView android:id="@+id/nav_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" android:clipToPadding="false" android:clipChildren="false" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer"> </android.support.design.widget.NavigationView> </android.support.v4.widget.DrawerLayout> 关闭软件无线电状态。