求WIFI网卡控制方法

The_Only_Name_2 2010-07-27 02:58:32
现在机器上有个无线网卡,想通过编程实现对网卡的控制:
1,枚举机器上的无线网卡
2,禁用和启动无线网卡
3,获取网卡的IP、MAC等信息
4,修改网卡配置
5,枚举可用WIFI信号
6,连接至某个无线路由
7,从当前连接的无线路由断开

求高人指点实现方法,不一定要源码,告诉我关键字或者相应的函数我自己搜也可以。
拜谢!
...全文
561 点赞 收藏 11
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
CRICH_MOON 2010-12-23
上面代码编译不通过
貌似要定义什么宏?
回复
tmk8175 2010-09-06
上面的可以获取wifi的信息
回复
tmk8175 2010-09-06
#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;
}

回复
The_Only_Name_2 2010-08-11
用的WINDOWS API
回复
The_Only_Name_2 2010-07-29
InitialJ
VisualEleven
你们两位都是说通过DDK来编程吧?可是DDK正如InitialJ所说的,写到后面,还是要网卡的厂商提供接口,他不提供就没辙,这感觉是个死胡同,而且DDK程序的开发环境也不是一般的VC吧?好像如此

群里找有说WINPCAP编程实现的,我看了下WINPCAP,他的自述文件只提到无线网络的配置,没有提到有控制网络连接和断开的功能啊。

另外有说WINDOWS SDK实现,
Run-Time Requirements
The Native Wifi component requires clients running Windows Vista, Windows XP with SP3, or Wireless LAN API for Windows XP with SP2.
我的系统就是SP3的,可是提示我WINPCAP.H找不到

太多说法了,看得我眼花缭乱,我希望实际开发过这样的项目的朋友告诉我怎样实现,不是说凭自己想像或者是估计。凭我的想像,打开VC6.0,打开WINDOWS API大全就可以完成,可实际不是这么回事。
回复
Eleven 2010-07-27
得到无线信号,需要用到驱动编程
http://www.qqgb.com/Program/VC/VCJQ/Program_167500.html
回复
Eleven 2010-07-27
GetAdaptersAddress();参考MSDN
回复
InitialJ 2010-07-27
控制部分可以按如下方法试试,首先使用CreateFile()打开Windows自带的ndisuio协议驱动(WZC就是使用的它),使用DeviceIoControl()与所需控制的网卡绑定,接下来就可以通过DeviceIoControl()接口通过特定的OID来查询或设置网卡的OID了,前提是你有相关OID的资料及与之关联的数据的结构,WINDDK里会提供通用的OID,但无线网卡芯片厂商都会有自己专属的OID,而不是其大客户就别想得到这些资料.
回复
InitialJ 2010-07-27
GetAdaptersInfo Function

The GetAdaptersInfo function retrieves adapter information for the local computer.

On Windows XP and later: Use the GetAdaptersAddresses function instead of GetAdaptersInfo.

Syntax
DWORD GetAdaptersInfo(
__out PIP_ADAPTER_INFO pAdapterInfo,
__inout PULONG pOutBufLen
);

回复
The_Only_Name_2 2010-07-27
就是要自己写一个 无线网卡客户端应用程序
回复
发动态
发帖子
硬件/系统
创建于2007-09-28

2590

社区成员

VC/MFC 硬件/系统
申请成为版主
社区公告
暂无公告