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;
}
因为以前从未接触过,
所以翻箱倒柜,不得要领。
今日偶然成功,亦不明所以。
这里给我的代码粘贴一下,
希望能给那些需要的人一些帮助。
也供我细细品味。
如有问题,大家也可一同研讨。
首先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;
}
相关文章推荐
- Native Wifi 中 WlanSetProfile 出现1206错误的几种可能及解决方法
- native wifi mac rssi
- 【在win7笔记本上启用wifi热点】win7_wlan.bat
- win7开机动画异常变成Vista那样的绿色滚动条的解决方法
- Win7共享无线 实现iPad 2 WiFi上网
- 你真的连在wifi上了吗?关于wlan休眠策略的经验分享
- 家园2 vista win7兼容补丁
- 开启笔记本win7的虚拟热点笔记本变成wifi教程
- win7技巧:windows 7 下简单命令创建wifi(手机可用)
- 笔记本分享wifi(Win7下)
- 笔记本电脑win7创建WIFI热点
- Win7 Wifi只能用于笔记本
- 遇到的问题-----win7配置wifi时设置网络后无线连接不出现
- win7 下建立android等设备可用的wifi 接入点--可共享宽带连接,本地连接,无线连接等
- VISTA、Win Server 2008、Win7 等系统音频系统底层API
- 使用Native WLAN API查找无线网络
- 如何删除Win7或者Vista中的系统文件
- vista 32/64 win7 32/64 修复程序
- 在Win7或Vista系统下新建AVD启动不了的解决方法!
- Win7 和 Vista UAC 问题