您的位置:首页 > 其它

vista win7 wlan native wifi rssi

2014-05-01 10:26 295 查看
这几天要在win7取得无线网卡周边ap的SSID和RSSI,

因为以前从未接触过,

所以翻箱倒柜,不得要领。

今日偶然成功,亦不明所以。

这里给我的代码粘贴一下,

希望能给那些需要的人一些帮助。

也供我细细品味。

如有问题,大家也可一同研讨。

首先msdn上说C:\Program Files\Microsoft SDKs\Windows\<version number>\Samples\NetDs\Wlan\AutoConfig

里有sample,大家打开自己的电脑,一般都会发现没有

去下个microsoft sdk,安装,可以找到sample,

可以参考下面的文件进行开发。

#include "stdafx.h"

#define _WIN32_DCOM

#include <windows.h>

#include <conio.h>

#include <objbase.h>

#include <rpcsal.h>

#include <objbase.h>

#include <msxml6.h>

#include <atlbase.h>

#include <iostream>

#include <iomanip>

// headers needed to use WLAN APIs

#include <wlanapi.h>

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

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

int count=0;

int dwClientVersion=2;

char *pReserved=NULL;

DWORD pdwNegotiatedVersion;

HANDLE phClientHandle=NULL;

int ERROR_TYPE;

PWLAN_INTERFACE_INFO_LIST pInterfaceList;

PWLAN_BSS_LIST pWlanBssList;

DOT11_SSID dot11Ssid = {0};

DOT11_BSS_TYPE dot11BssType = dot11_BSS_type_any;

ERROR_TYPE=WlanOpenHandle(dwClientVersion,pReserved,&pdwNegotiatedVersion,&phClientHandle);

if(ERROR_TYPE!=ERROR_SUCCESS)

{

printf("something is wrong with WlanOpenHndle()\n");

return -1;

}

ERROR_TYPE=WlanEnumInterfaces(phClientHandle,pReserved,&pInterfaceList);

if(ERROR_TYPE!=ERROR_SUCCESS)

{

printf("something is wrong with WlanEnumInterfaces()\n");

return -1;

}

ERROR_TYPE=WlanGetNetworkBssList(phClientHandle,&pInterfaceList[0].InterfaceInfo[0].InterfaceGuid,NULL,dot11BssType,NULL,

pReserved,&pWlanBssList);

if(ERROR_TYPE!=ERROR_SUCCESS)

{

printf("something is wrong with WlanGetNetworkBssList()\n");

return -1;

}

while(count<pWlanBssList->dwNumberOfItems)

{

cout<<pWlanBssList->wlanBssEntries[count].dot11Ssid.ucSSID<<" "<<pWlanBssList->wlanBssEntries[count].lRssi<<endl;

count++;

}

printf("%s,%ld\n",pWlanBssList->wlanBssEntries[0].dot11Ssid.ucSSID,pWlanBssList->wlanBssEntries[0].lRssi);

printf("succeed\n");

getch();

return 0;

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