• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            如果是XP sp2,而且安裝了Wlanapi.dll,可以直接使用WlanEnumInterfaces枚舉無線網(wǎng)卡


            http://msdn.microsoft.com/en-us/library/ms706716(VS.85).aspx

            The WlanEnumInterfaces function enumerates all of the wireless LAN interfaces currently enabled on the local computer.

            Syntax

            DWORD WINAPI WlanEnumInterfaces(
            __in        HANDLE hClientHandle,
            __reserved  PVOID pReserved,
            __out       PWLAN_INTERFACE_INFO_LIST *ppInterfaceList
            );
            

            Parameters

            hClientHandle [in]

            The client's session handle, obtained by a previous call to the WlanOpenHandle function.

            pReserved [in]

            Reserved for future use. This parameter must be set to NULL.

            ppInterfaceList [out]

            A pointer to storage for a pointer to receive the returned list of wireless LAN interfaces in a WLAN_INTERFACE_INFO_LIST structure.

            The buffer for the WLAN_INTERFACE_INFO_LIST returned is allocated by the WlanEnumInterfaces function if the call succeeds.

            Return Value

            If the function succeeds, the return value is ERROR_SUCCESS.

            If the function fails, the return value may be one of the following return codes.

            Return code Description
            ERROR_INVALID_PARAMETER

            A parameter is incorrect. This error is returned if the hClientHandle or ppInterfaceList parameter is NULL. This error is returned if the pReserved is not NULL. This error is also returned if the hClientHandle parameter is not valid.

            ERROR_INVALID_HANDLE

            The handle hClientHandle was not found in the handle table.

            RPC_STATUS

            Various error codes.

            ERROR_NOT_ENOUGH_MEMORY

            Not enough memory is available to process this request and allocate memory for the query results.

             

            Remarks

            The WlanEnumInterfaces function allocates memory for the list of returned interfaces that is returned in the buffer pointed to by the ppInterfaceList parameter when the function succeeds. The memory used for the buffer pointed to by ppInterfaceList parameter should be released by calling the WlanFreeMemory function after the buffer is no longer needed.

            Examples

            The following example enumerates the wireless LAN interfaces on the local computer and prints values from the retrieved WLAN_INTERFACE_INFO_LIST structure and the enumerated WLAN_INTERFACE_INFO structures.

            Note  This example will fail to load on Windows Server 2008 and Windows Server 2008 R2 if the Wireless LAN Service is not installed and started.

            #ifndef UNICODE
            #define UNICODE
            #endif
            #include <windows.h>
            #include <wlanapi.h>
            #include <objbase.h>
            #include <wtypes.h>
            #include <stdio.h>
            #include <stdlib.h>
            // Need to link with Wlanapi.lib and Ole32.lib
            #pragma comment(lib, "wlanapi.lib")
            #pragma comment(lib, "ole32.lib")
            int wmain()
            {
            // Declare and initialize variables.
            HANDLE hClient = NULL;
            DWORD dwMaxClient = 2;   //
            DWORD dwCurVersion = 0;
            DWORD dwResult = 0;
            int iRet = 0;
            WCHAR GuidString[40] = {0};
            int i;
            /* variables used for WlanEnumInterfaces  */
            PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
            PWLAN_INTERFACE_INFO pIfInfo = NULL;
            dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
            if (dwResult != ERROR_SUCCESS)  {
            wprintf(L"WlanOpenHandle failed with error: %u\n", dwResult);
            // FormatMessage can be used to find out why the function failed
            return 1;
            }
            dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList);
            if (dwResult != ERROR_SUCCESS)  {
            wprintf(L"WlanEnumInterfaces failed with error: %u\n", dwResult);
            // FormatMessage can be used to find out why the function failed
            return 1;
            }
            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[%d]:\t %lu\n", i, i);
            iRet = StringFromGUID2(pIfInfo->InterfaceGuid, (LPOLESTR) &GuidString, 39);
            // For c rather than C++ source code, the above line needs to be
            // iRet = StringFromGUID2(&pIfInfo->InterfaceGuid, (LPOLESTR) &GuidString, 39);
            if (iRet == 0)
            wprintf(L"StringFromGUID2 failed\n");
            else {
            wprintf(L"  InterfaceGUID[%d]: %ws\n",i, GuidString);
            }
            wprintf(L"  Interface Description[%d]: %ws", i,
            pIfInfo->strInterfaceDescription);
            wprintf(L"\n");
            wprintf(L"  Interface State[%d]:\t ", i);
            switch (pIfInfo->isState) {
            case wlan_interface_state_not_ready:
            wprintf(L"Not ready\n");
            break;
            case wlan_interface_state_connected:
            wprintf(L"Connected\n");
            break;
            case wlan_interface_state_ad_hoc_network_formed:
            wprintf(L"First node in a ad hoc network\n");
            break;
            case wlan_interface_state_disconnecting:
            wprintf(L"Disconnecting\n");
            break;
            case wlan_interface_state_disconnected:
            wprintf(L"Not connected\n");
            break;
            case wlan_interface_state_associating:
            wprintf(L"Attempting to associate with a network\n");
            break;
            case wlan_interface_state_discovering:
            wprintf(L"Auto configuration is discovering settings for the network\n");
            break;
            case wlan_interface_state_authenticating:
            wprintf(L"In process of authenticating\n");
            break;
            default:
            wprintf(L"Unknown state %ld\n", pIfInfo->isState);
            break;
            }
            wprintf(L"\n");
            }
            }
            if (pIfList != NULL) {
            WlanFreeMemory(pIfList);
            pIfList = NULL;
            }
            return 0;
            }
            

            Requirements

            Minimum supported client

            Windows Vista, Windows XP with SP3

            Minimum supported server

            Windows Server 2008

            Redistributable

            Wireless LAN API for Windows XP with SP2

            Header

            Wlanapi.h (include Wlanapi.h)

            Library

            Wlanapi.lib

            DLL

            Wlanapi.dll

            posted on 2010-12-16 09:01 wrh 閱讀(2657) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            導(dǎo)航

            <2010年5月>
            2526272829301
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            統(tǒng)計(jì)

            常用鏈接

            留言簿(19)

            隨筆檔案

            文章檔案

            收藏夾

            搜索

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            久久久久av无码免费网| 久久国产精品免费一区二区三区| 久久综合久久伊人| 伊人久久五月天| 精品久久久久久成人AV| 精品久久久久久无码人妻热| 久久久久久久97| 国产999精品久久久久久| 亚洲精品第一综合99久久| 国产精品久久一区二区三区| 日本精品久久久久久久久免费| 久久A级毛片免费观看| 思思久久99热免费精品6| 国产精品9999久久久久| 丁香色欲久久久久久综合网| 国产农村妇女毛片精品久久| av午夜福利一片免费看久久| 久久久久青草线蕉综合超碰| 久久精品国产亚洲AV不卡| 久久久久成人精品无码中文字幕| 亚洲精品成人久久久| 国内精品久久久久久久亚洲| 国产精品久久久久久| 无码国内精品久久人妻| 久久人人添人人爽添人人片牛牛| 久久99精品久久久久久不卡| 国产99精品久久| 久久99国产精品久久| 7777久久亚洲中文字幕| 国内精品人妻无码久久久影院 | 人妻少妇久久中文字幕| 人人狠狠综合久久亚洲高清| 国内精品久久久久久久亚洲| 久久99国产精品二区不卡| 91精品国产9l久久久久| 久久精品国产99久久无毒不卡| 欧洲成人午夜精品无码区久久| 日韩欧美亚洲综合久久| 99久久无色码中文字幕人妻 | 蜜臀av性久久久久蜜臀aⅴ| 国产aⅴ激情无码久久|