wifi的一些操作

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;

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值