vista win7 wlan native wifi rssi

这几天要在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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值