1.GetAdaptersInfo(pAdapterInfo, &bufLen)获取设备;
HANDLE hNdisUio = CreateFile(NDISUIO_DEVICE_NAME,
GENERIC_ALL,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE)INVALID_HANDLE_VALUE);
DWORD dwBytesReturned = 0;
NDISUIO_QUERY_OID NDISUIOQueryOid = {0};
NDISUIOQueryOid.Oid = OID_GEN_PHYSICAL_MEDIUM;
NDIS_PHYSICAL_MEDIUM MinorType;
gp_int32_t iDeviceCounts = 0;
gp_int32_t iIndex = 0;
while(pAdapterInfo)
{
#ifdef UNICODE
TCHAR tszDeviceName[128] = {_T('/0')};
MultiByteToWideChar(CP_ACP, 0, pAdapterInfo->AdapterName, strlen(pAdapterInfo->AdapterName), tszDeviceName, 128);
NDISUIOQueryOid.ptcDeviceName = tszDeviceName;
#else
NDISUIOQueryOid->ptcDeviceName = pAdapterInfo->AdapterName;
#endif
iRet = DeviceIoControl(hNdisUio,
IOCTL_NDISUIO_QUERY_OID_VALUE,
&NDISUIOQueryOid,
sizeof(NDISUIOQueryOid),
&NDISUIOQueryOid,
sizeof(NDISUIOQueryOid),
&dwBytesReturned,
NULL);
if(!iRet)
{
MinorType = NdisPhysicalMediumUnspecified;
break;
}
else
{
MinorType = *(NDIS_PHYSICAL_MEDIUM*)NDISUIOQueryOid.Data;
}
if( MinorType == NdisPhysicalMediumWirelessLan)
{
wifi设置
}
}
2、macaddress
pQueryOid->Oid = OID_802_3_PERMANENT_ADDRESS;
swprintf(pDevInfo->wszDeviceId,
L"%.2X%.2X%.2X%.2X%.2X%.2X",
pQueryOid->Data[0],
3、OID_GEN_LINK_SPEED
4、network OID_802_11_BSSID_LIST
pQueryOid->Data[1],
pQueryOid->Data[2],
pQueryOid->Data[3],
pQueryOid->Data[4],
pQueryOid->Data[5]);
5、OID_802_11_BSSID
This object identifier (OID), when set, requests that a miniport driver assign a specified value to the media access control (MAC) address of the access point associated with the NIC 。The miniport driver should return an error code of NDIS_STATUS_ADAPTER_NOT_READY if the NIC is not associated with an access point
OID_802_11_SSID
When queried, this object identifier requests the miniport driver to return the associated NIC's SSID. If the NIC is not associated with a SSID, the miniport driver returns the value from the last OID_802_11_SSID set, or returns the SSID of the last access point with which the NIC was associated
可以用过MAC与OID_802_11_BSSID_LIST中得到来获取当前连接ssid基本信息
6、OID_802_11_INFRASTRUCTURE_MODE
7、OID_802_11_CONFIGURATION channel
8、OID_802_11_RSSI signal
9、OID_GEN_LINK_SPEED
10、OID_GEN_MEDIA_CONNECT_STATUS device status
11、Statistic
GetAdaptersInfo(IP_ADAPTER_INFO *pAdapter, &dwBufLen);
ifRow.dwIndex = pAdapter->dwIndex ;
if( GetIfEntry( &ifRow ) != NO_ERROR )
12、PNDISUIO_SET_OID pSetOid =(PNDISUIO_SET_OID)inbuf;
pSetOid->Oid = OID_802_11_DISASSOCIATE;
OID_802_11_DISASSOCIATE dissconnect
13、connect
wchar_t wszSSID[SSID_LENGTH] = {L'/0'};
wchar_t wszKey[256] = {L'/0'};
wstring sProfileXML;
wstring sSecurityKey;
wcscpy(wszSSID, ssid.wszSsid);
MultiByteToWideChar(CP_ACP, 0, pcszSecurityKey, strlen(pcszSecurityKey), wszKey, 256);
sSecurityKey = wszKey;
iRet = GenerateProfileXMLString(wszSSID, !bIsAdhoc, eAuthenType, eEncryType, eEapType, sSecurityKey,1, sProfileXML);//bNetInternetOrNetCrop
LPWSTR lpszResultXML = NULL;
HRESULT hr = S_OK;
hr = DMProcessConfigXML(sProfileXML.c_str(), CFGFLAG_PROCESS,(LPWSTR *)&lpszResultXML);
delete []lpszResultXML, lpszResultXML = NULL;
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lmyuanhang/archive/2010/02/25/5326196.aspx