您的位置:首页 > 其它

Windows Embedded Compact 7获取WIFI热点

2012-05-02 10:53 351 查看
程序运行的环境为Windows embedded compact 7,VS2008

之前一直想采用WZC一类的函数来获得WINCE 7.0中的WIFI相关信息及热点,但一直都无果,后来在查看MSDN才知道Wlan一类的函数在WINCE7.0上可用来实现这些功能。目前暂时用来获取WIFI的相关信息及热点。

具体操作如下:

WlanOpenHandle:打开服务的连接;

WlanEnumInterfaces:枚举当前所有的有效无线网卡;

WlanGetAvailableNetworkList:获取当前可用的网络接口;

WlanFreeMemory:释放进行WlanEnumInterface和WlanGetAvailableNetworkList时分配的空间。

具体代码如下:

[cpp]
view plaincopyprint?

int CwlanwifiDlg::GetWifiAccessPoint()
{
// Declare and initialize variables.

// 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;

int iRSSI = 0;

dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
if (dwResult != ERROR_SUCCESS) {
RETAILMSG(OUTPUT_LOGMSG,(L"WlanOpenHandle failed with error: %u\r\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)
{
RETAILMSG(OUTPUT_LOGMSG,(L"WlanEnumInterfaces failed with error: %u\r\n", dwResult));
return 1;
// You can use FormatMessage here to find out why the function failed

}
else
{
RETAILMSG(OUTPUT_LOGMSG,(L"Num Entries: %d\r\n", pIfList->dwNumberOfItems));
RETAILMSG(OUTPUT_LOGMSG,(L"Current Index: %d\r\n", pIfList->dwIndex));

for (i = 0; i < (int)pIfList->dwNumberOfItems; i++)
{
pIfInfo = (WLAN_INTERFACE_INFO *) &pIfList->InterfaceInfo[i];
RETAILMSG(OUTPUT_LOGMSG,(L" Interface Index[%u]:\t %lu\r\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)
RETAILMSG(OUTPUT_LOGMSG,(L"StringFromGUID2 failed\r\n"));
else
RETAILMSG(OUTPUT_LOGMSG,(L" InterfaceGUID[%d]: %ws\r\n",i, GuidString));

RETAILMSG(OUTPUT_LOGMSG,(L" Interface Description[%d]: %s\r\n", i,
&pIfInfo->strInterfaceDescription));

RETAILMSG(OUTPUT_LOGMSG,(L" Interface State[%d]:\t ", i));
switch (pIfInfo->isState) {
case wlan_interface_state_not_ready:
RETAILMSG(OUTPUT_LOGMSG,(L"Not ready\r\n"));
break;
case wlan_interface_state_connected:
RETAILMSG(OUTPUT_LOGMSG,(L"Connected\r\n"));
break;
case wlan_interface_state_ad_hoc_network_formed:
RETAILMSG(OUTPUT_LOGMSG,(L"First node in a ad hoc network\r\n"));
break;
case wlan_interface_state_disconnecting:
RETAILMSG(OUTPUT_LOGMSG,(L"Disconnecting\r\n"));
break;
case wlan_interface_state_disconnected:
RETAILMSG(OUTPUT_LOGMSG,(L"Not connected\r\n"));
break;
case wlan_interface_state_associating:
RETAILMSG(OUTPUT_LOGMSG,(L"Attempting to associate with a network\r\n"));
break;
case wlan_interface_state_discovering:
RETAILMSG(OUTPUT_LOGMSG,(L"Auto configuration is discovering settings for the network\r\n"));
break;
case wlan_interface_state_authenticating:
RETAILMSG(OUTPUT_LOGMSG,(L"In process of authenticating\r\n"));
break;
default:
RETAILMSG(OUTPUT_LOGMSG,(L"Unknown state %ld\r\n", pIfInfo->isState));
break;
}
RETAILMSG(OUTPUT_LOGMSG,(L"\r\n"));

//获得可用的无线网列表
dwResult = WlanGetAvailableNetworkList(hClient,
&pIfInfo->InterfaceGuid,
0,
NULL,
&pBssList);

if (dwResult != ERROR_SUCCESS)
{
RETAILMSG(OUTPUT_LOGMSG,(L"WlanGetAvailableNetworkList failed with error: %u\r\n",
dwResult));
dwRetVal = 1;
// You can use FormatMessage to find out why the function failed

}
else
{
RETAILMSG(OUTPUT_LOGMSG, (L"WLAN_AVAILABLE_NETWORK_LIST for this interface\r\n"));
RETAILMSG(OUTPUT_LOGMSG,(L"Num Entries: %d\r\n", pBssList->dwNumberOfItems));

for (j = 0; j < pBssList->dwNumberOfItems; j++)
{
pBssEntry = (WLAN_AVAILABLE_NETWORK *)&pBssList->Network[j];
RETAILMSG(OUTPUT_LOGMSG,(L" Profile Name[%u]: %s\r\n", j, &pBssEntry->strProfileName));
RETAILMSG(OUTPUT_LOGMSG,(L" SSID[%u]:\t\t ", j));
if (pBssEntry->dot11Ssid.uSSIDLength == 0)
RETAILMSG(OUTPUT_LOGMSG,(L"\r\n"));
else
{
CString str = _T("");
str = pBssEntry->dot11Ssid.ucSSID;

RETAILMSG(OUTPUT_LOGMSG,(L"%s\r\n", str));
RETAILMSG(OUTPUT_LOGMSG,(L"%s\r\n", &pBssEntry->dot11Ssid.ucSSID));
}

RETAILMSG(OUTPUT_LOGMSG,(L"BSS Network type[%u]:\t ", j));
switch (pBssEntry->dot11BssType)
{
case dot11_BSS_type_infrastructure :
RETAILMSG(OUTPUT_LOGMSG,(L"Infrastructure (%u)\r\n", pBssEntry->dot11BssType));
break;
case dot11_BSS_type_independent:
RETAILMSG(OUTPUT_LOGMSG,(L"Infrastructure (%u)\r\n", pBssEntry->dot11BssType));
break;
default:
RETAILMSG(OUTPUT_LOGMSG,(L"Other (%lu)\r\n", pBssEntry->dot11BssType));
break;
}

RETAILMSG(OUTPUT_LOGMSG,(L" Number of BSSIDs[%u]:\t %u\r\n", j, pBssEntry->uNumberOfBssids));
RETAILMSG(OUTPUT_LOGMSG,(L" Connectable[%u]:\t ", j));
if (pBssEntry->bNetworkConnectable)
RETAILMSG(OUTPUT_LOGMSG,(L"Yes\r\n"));
else
{
RETAILMSG(OUTPUT_LOGMSG,(L"No\r\n"));
RETAILMSG(OUTPUT_LOGMSG,(L" Not connectable WLAN_REASON_CODE value[%u]:\t %u\r\n", j,
pBssEntry->wlanNotConnectableReason));
}

RETAILMSG(OUTPUT_LOGMSG,(L"Number of PHY types supported[%u]:\t %u\r\n", j, pBssEntry->uNumberOfPhyTypes));

if (pBssEntry->wlanSignalQuality == 0)
iRSSI = -100;
else if (pBssEntry->wlanSignalQuality == 100)
iRSSI = -50;
else
iRSSI = -100 + (pBssEntry->wlanSignalQuality/2);

RETAILMSG(OUTPUT_LOGMSG,(L" Signal Quality[%u]:\t %u (RSSI: %i dBm)\r\n", j,
pBssEntry->wlanSignalQuality, iRSSI));

RETAILMSG(OUTPUT_LOGMSG,(L" Security Enabled[%u]:\t ", j));
if (pBssEntry->bSecurityEnabled)
RETAILMSG(OUTPUT_LOGMSG,(L"Yes\r\n"));
else
RETAILMSG(OUTPUT_LOGMSG,(L"No\r\n"));
//身份验证类型
RETAILMSG(OUTPUT_LOGMSG,(L" Default AuthAlgorithm[%u]: ", j));
switch (pBssEntry->dot11DefaultAuthAlgorithm)
{
case DOT11_AUTH_ALGO_80211_OPEN:
RETAILMSG(OUTPUT_LOGMSG,(L"802.11 Open (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_80211_SHARED_KEY:
RETAILMSG(OUTPUT_LOGMSG,(L"802.11 Shared (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_WPA:
RETAILMSG(OUTPUT_LOGMSG,(L"WPA (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_WPA_PSK:
RETAILMSG(OUTPUT_LOGMSG,(L"WPA-PSK (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_WPA_NONE:
RETAILMSG(OUTPUT_LOGMSG,(L"WPA-None (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_RSNA:
RETAILMSG(OUTPUT_LOGMSG,(L"RSNA (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_RSNA_PSK:
RETAILMSG(OUTPUT_LOGMSG,(L"RSNA with PSK(%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
default:
RETAILMSG(OUTPUT_LOGMSG,(L"Other (%lu)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
}

//加密类型
RETAILMSG(OUTPUT_LOGMSG,(L" Default CipherAlgorithm[%u]: ", j));
switch (pBssEntry->dot11DefaultCipherAlgorithm)
{
case DOT11_CIPHER_ALGO_NONE:
RETAILMSG(OUTPUT_LOGMSG,(L"None (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_WEP40:
RETAILMSG(OUTPUT_LOGMSG,(L"WEP-40 (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_TKIP:
RETAILMSG(OUTPUT_LOGMSG,(L"TKIP (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_CCMP:
RETAILMSG(OUTPUT_LOGMSG,(L"CCMP (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_WEP104:
RETAILMSG(OUTPUT_LOGMSG,(L"WEP-104 (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_WEP:
RETAILMSG(OUTPUT_LOGMSG,(L"WEP (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
default:
RETAILMSG(OUTPUT_LOGMSG,(L"Other (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
}

RETAILMSG(OUTPUT_LOGMSG,(L" Flags[%u]:\t 0x%x", j, pBssEntry->dwFlags));
if (pBssEntry->dwFlags)
{
if (pBssEntry->dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED)
RETAILMSG(OUTPUT_LOGMSG,(L" - Currently connected"));
if (pBssEntry->dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED)
RETAILMSG(OUTPUT_LOGMSG,(L" - Has profile"));
}
RETAILMSG(OUTPUT_LOGMSG,(L"\r\n"));

RETAILMSG(OUTPUT_LOGMSG,(L"\r\n"));
}//for (j = 0; j < pBssList->dwNumberOfItems; j++)

}//else 无线网个数

}//for (i = 0; i < (int)pIfList->dwNumberOfItems; i++)

}//else 无线适配器

// 释放空间
if (pBssList != NULL)
{
WlanFreeMemory(pBssList);
pBssList = NULL;
}

if (pIfList != NULL)
{
WlanFreeMemory(pIfList);
pIfList = NULL;
}

return dwRetVal;
}

int CwlanwifiDlg::GetWifiAccessPoint()
{
// Declare and initialize variables.

// 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;

int iRSSI = 0;

dwResult = WlanOpenHandle(dwMaxClient, NULL, &dwCurVersion, &hClient);
if (dwResult != ERROR_SUCCESS) {
RETAILMSG(OUTPUT_LOGMSG,(L"WlanOpenHandle failed with error: %u\r\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)
{
RETAILMSG(OUTPUT_LOGMSG,(L"WlanEnumInterfaces failed with error: %u\r\n", dwResult));
return 1;
// You can use FormatMessage here to find out why the function failed
}
else
{
RETAILMSG(OUTPUT_LOGMSG,(L"Num Entries: %d\r\n", pIfList->dwNumberOfItems));
RETAILMSG(OUTPUT_LOGMSG,(L"Current Index: %d\r\n", pIfList->dwIndex));

for (i = 0; i < (int)pIfList->dwNumberOfItems; i++)
{
pIfInfo = (WLAN_INTERFACE_INFO *) &pIfList->InterfaceInfo[i];
RETAILMSG(OUTPUT_LOGMSG,(L" Interface Index[%u]:\t %lu\r\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)
RETAILMSG(OUTPUT_LOGMSG,(L"StringFromGUID2 failed\r\n"));
else
RETAILMSG(OUTPUT_LOGMSG,(L" InterfaceGUID[%d]: %ws\r\n",i, GuidString));

RETAILMSG(OUTPUT_LOGMSG,(L" Interface Description[%d]: %s\r\n", i,
&pIfInfo->strInterfaceDescription));

RETAILMSG(OUTPUT_LOGMSG,(L" Interface State[%d]:\t ", i));
switch (pIfInfo->isState) {
case wlan_interface_state_not_ready:
RETAILMSG(OUTPUT_LOGMSG,(L"Not ready\r\n"));
break;
case wlan_interface_state_connected:
RETAILMSG(OUTPUT_LOGMSG,(L"Connected\r\n"));
break;
case wlan_interface_state_ad_hoc_network_formed:
RETAILMSG(OUTPUT_LOGMSG,(L"First node in a ad hoc network\r\n"));
break;
case wlan_interface_state_disconnecting:
RETAILMSG(OUTPUT_LOGMSG,(L"Disconnecting\r\n"));
break;
case wlan_interface_state_disconnected:
RETAILMSG(OUTPUT_LOGMSG,(L"Not connected\r\n"));
break;
case wlan_interface_state_associating:
RETAILMSG(OUTPUT_LOGMSG,(L"Attempting to associate with a network\r\n"));
break;
case wlan_interface_state_discovering:
RETAILMSG(OUTPUT_LOGMSG,(L"Auto configuration is discovering settings for the network\r\n"));
break;
case wlan_interface_state_authenticating:
RETAILMSG(OUTPUT_LOGMSG,(L"In process of authenticating\r\n"));
break;
default:
RETAILMSG(OUTPUT_LOGMSG,(L"Unknown state %ld\r\n", pIfInfo->isState));
break;
}
RETAILMSG(OUTPUT_LOGMSG,(L"\r\n"));

//获得可用的无线网列表
dwResult = WlanGetAvailableNetworkList(hClient,
&pIfInfo->InterfaceGuid,
0,
NULL,
&pBssList);

if (dwResult != ERROR_SUCCESS)
{
RETAILMSG(OUTPUT_LOGMSG,(L"WlanGetAvailableNetworkList failed with error: %u\r\n",
dwResult));
dwRetVal = 1;
// You can use FormatMessage to find out why the function failed
}
else
{
RETAILMSG(OUTPUT_LOGMSG, (L"WLAN_AVAILABLE_NETWORK_LIST for this interface\r\n"));
RETAILMSG(OUTPUT_LOGMSG,(L"Num Entries: %d\r\n", pBssList->dwNumberOfItems));

for (j = 0; j < pBssList->dwNumberOfItems; j++)
{
pBssEntry = (WLAN_AVAILABLE_NETWORK *)&pBssList->Network[j];
RETAILMSG(OUTPUT_LOGMSG,(L" Profile Name[%u]: %s\r\n", j, &pBssEntry->strProfileName));
RETAILMSG(OUTPUT_LOGMSG,(L" SSID[%u]:\t\t ", j));
if (pBssEntry->dot11Ssid.uSSIDLength == 0)
RETAILMSG(OUTPUT_LOGMSG,(L"\r\n"));
else
{
CString str = _T("");
str = pBssEntry->dot11Ssid.ucSSID;

RETAILMSG(OUTPUT_LOGMSG,(L"%s\r\n", str));
RETAILMSG(OUTPUT_LOGMSG,(L"%s\r\n", &pBssEntry->dot11Ssid.ucSSID));
}

RETAILMSG(OUTPUT_LOGMSG,(L"BSS Network type[%u]:\t ", j));
switch (pBssEntry->dot11BssType)
{
case dot11_BSS_type_infrastructure :
RETAILMSG(OUTPUT_LOGMSG,(L"Infrastructure (%u)\r\n", pBssEntry->dot11BssType));
break;
case dot11_BSS_type_independent:
RETAILMSG(OUTPUT_LOGMSG,(L"Infrastructure (%u)\r\n", pBssEntry->dot11BssType));
break;
default:
RETAILMSG(OUTPUT_LOGMSG,(L"Other (%lu)\r\n", pBssEntry->dot11BssType));
break;
}

RETAILMSG(OUTPUT_LOGMSG,(L" Number of BSSIDs[%u]:\t %u\r\n", j, pBssEntry->uNumberOfBssids));
RETAILMSG(OUTPUT_LOGMSG,(L" Connectable[%u]:\t ", j));
if (pBssEntry->bNetworkConnectable)
RETAILMSG(OUTPUT_LOGMSG,(L"Yes\r\n"));
else
{
RETAILMSG(OUTPUT_LOGMSG,(L"No\r\n"));
RETAILMSG(OUTPUT_LOGMSG,(L" Not connectable WLAN_REASON_CODE value[%u]:\t %u\r\n", j,
pBssEntry->wlanNotConnectableReason));
}

RETAILMSG(OUTPUT_LOGMSG,(L"Number of PHY types supported[%u]:\t %u\r\n", j, pBssEntry->uNumberOfPhyTypes));

if (pBssEntry->wlanSignalQuality == 0)
iRSSI = -100;
else if (pBssEntry->wlanSignalQuality == 100)
iRSSI = -50;
else
iRSSI = -100 + (pBssEntry->wlanSignalQuality/2);

RETAILMSG(OUTPUT_LOGMSG,(L" Signal Quality[%u]:\t %u (RSSI: %i dBm)\r\n", j,
pBssEntry->wlanSignalQuality, iRSSI));

RETAILMSG(OUTPUT_LOGMSG,(L" Security Enabled[%u]:\t ", j));
if (pBssEntry->bSecurityEnabled)
RETAILMSG(OUTPUT_LOGMSG,(L"Yes\r\n"));
else
RETAILMSG(OUTPUT_LOGMSG,(L"No\r\n"));
//身份验证类型
RETAILMSG(OUTPUT_LOGMSG,(L" Default AuthAlgorithm[%u]: ", j));
switch (pBssEntry->dot11DefaultAuthAlgorithm)
{
case DOT11_AUTH_ALGO_80211_OPEN:
RETAILMSG(OUTPUT_LOGMSG,(L"802.11 Open (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_80211_SHARED_KEY:
RETAILMSG(OUTPUT_LOGMSG,(L"802.11 Shared (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_WPA:
RETAILMSG(OUTPUT_LOGMSG,(L"WPA (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_WPA_PSK:
RETAILMSG(OUTPUT_LOGMSG,(L"WPA-PSK (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_WPA_NONE:
RETAILMSG(OUTPUT_LOGMSG,(L"WPA-None (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_RSNA:
RETAILMSG(OUTPUT_LOGMSG,(L"RSNA (%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
case DOT11_AUTH_ALGO_RSNA_PSK:
RETAILMSG(OUTPUT_LOGMSG,(L"RSNA with PSK(%u)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
default:
RETAILMSG(OUTPUT_LOGMSG,(L"Other (%lu)\r\n", pBssEntry->dot11DefaultAuthAlgorithm));
break;
}

//加密类型
RETAILMSG(OUTPUT_LOGMSG,(L" Default CipherAlgorithm[%u]: ", j));
switch (pBssEntry->dot11DefaultCipherAlgorithm)
{
case DOT11_CIPHER_ALGO_NONE:
RETAILMSG(OUTPUT_LOGMSG,(L"None (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_WEP40:
RETAILMSG(OUTPUT_LOGMSG,(L"WEP-40 (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_TKIP:
RETAILMSG(OUTPUT_LOGMSG,(L"TKIP (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_CCMP:
RETAILMSG(OUTPUT_LOGMSG,(L"CCMP (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_WEP104:
RETAILMSG(OUTPUT_LOGMSG,(L"WEP-104 (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
case DOT11_CIPHER_ALGO_WEP:
RETAILMSG(OUTPUT_LOGMSG,(L"WEP (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
default:
RETAILMSG(OUTPUT_LOGMSG,(L"Other (0x%x)\r\n", pBssEntry->dot11DefaultCipherAlgorithm));
break;
}

RETAILMSG(OUTPUT_LOGMSG,(L" Flags[%u]:\t 0x%x", j, pBssEntry->dwFlags));
if (pBssEntry->dwFlags)
{
if (pBssEntry->dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED)
RETAILMSG(OUTPUT_LOGMSG,(L" - Currently connected"));
if (pBssEntry->dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED)
RETAILMSG(OUTPUT_LOGMSG,(L" - Has profile"));
}
RETAILMSG(OUTPUT_LOGMSG,(L"\r\n"));

RETAILMSG(OUTPUT_LOGMSG,(L"\r\n"));
}//for (j = 0; j < pBssList->dwNumberOfItems; j++)
}//else 无线网个数
}//for (i = 0; i < (int)pIfList->dwNumberOfItems; i++)
}//else 无线适配器

// 释放空间
if (pBssList != NULL)
{
WlanFreeMemory(pBssList);
pBssList = NULL;
}

if (pIfList != NULL)
{
WlanFreeMemory(pIfList);
pIfList = NULL;
}

return dwRetVal;
}

需要附加头文件:

#include <wlanapi.h>

#pragma comment(lib, "wlanapi.lib")

定义的宏

//定义输入LOG信息宏

#define OUTPUT_LOGMSG 1

编译时可能会出错,但我把其中出错的地方注释掉,就可以编译了,而且能够得到相应的结果。

修改文件 ntddndis.h 修改如下:

#define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE

line 3958 //typedef IF_COUNTED_STRING NDIS_IF_COUNTED_STRING, *PNDIS_IF_COUNTED_STRING;

#define NDIS_MAX_PHYS_ADDRESS_LENGTH IF_MAX_PHYS_ADDRESS_LENGTH

line 3960 //typedef IF_PHYSICAL_ADDRESS NDIS_IF_PHYSICAL_ADDRESS, *PNDIS_IF_PHYSICAL_ADDRESS;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: