共用方式為


WLAN_REALTIME_CONNECTION_QUALITY結構 (wlanapi.h)

重要

有些資訊與發行前版本產品有關,在正式發行前可能會大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。

表示描述指定介面上連接質量的屬性。

語法

typedef struct _WLAN_REALTIME_CONNECTION_QUALITY {
  DOT11_PHY_TYPE                             dot11PhyType;
  ULONG                                      ulLinkQuality;
  ULONG                                      ulRxRate;
  ULONG                                      ulTxRate;
  BOOL                                       bIsMLOConnection;
  ULONG                                      ulNumLinks;
  WLAN_REALTIME_CONNECTION_QUALITY_LINK_INFO linksInfo[1];
} WLAN_REALTIME_CONNECTION_QUALITY, *PWLAN_REALTIME_CONNECTION_QUALITY;

成員

dot11PhyType

表示關聯實體類型的 DOT11_PHY_TYPE 值。

ulLinkQuality

代表連線訊號品質的 ULONG 百分比值。 這個成員包含介於 0 到 100 之間的值。 值為 0 表示實際 RSSI 訊號強度為 -100 dbm。 值為 100 表示實際 RSSI 訊號強度為 -50 dbm。 您可以使用線性插補來計算 ulLinkQuality 值介於 1 到 99 之間的 RSSI 訊號強度值。

ulRxRate

包含關聯的接收速率。

ulTxRate

包含關聯的傳輸速率。

bIsMLOConnection

表示這是 MLO) 連線 (多重連結作業。

ulNumLinks

已連線的連結數目。

linksInfo[1]

大小 ulNumLinksWLAN_REALTIME_CONNECTION_QUALITY_LINK_INFO。 每個元素都包含不同連線連結的相關信息。

備註

範例

DWORD IsWLANLinkSpeedSufficient(
    GUID* interfaceGuid,
    const ULONG minRequiredLinkQuality,
    const ULONG requiredRxRate,
    const ULONG requiredTxRate,
    bool* isSufficient)
{
    wil::unique_wlan_handle clientHandle;
    DWORD maxClientVersion = 2;
    DWORD currentClientVersion = 0;
    DWORD result = WlanOpenHandle(maxClientVersion, nullptr, &currentClientVersion, &clientHandle);
    if (result != ERROR_SUCCESS) 
    {
        wprintf(L"WlanOpenHandle failed with error: %u\n", result);
        return result;
    }

    DWORD connectionQualitySize = 0;
    wil::unique_wlan_ptr<WLAN_REALTIME_CONNECTION_QUALITY> connectionQuality;
    result = WlanQueryInterface(
        clientHandle.get(), 
        interfaceGuid,
        wlan_intf_opcode_realtime_connection_quality,
        nullptr,
        &connectionQualitySize,
        wil::out_param_ptr<void**>(connectionQuality),
        nullptr);
    if (result != ERROR_SUCCESS) 
    {
        wprintf(L"WlanQueryInterface failed with error: %u\n", result);
        return result;
    }

    if (connectionQuality->ulLinkQuality < minRequiredLinkQuality || 
        connectionQuality->ulRxRate < requiredRxRate ||
        connectionQuality->ulTxRate < requiredTxRate)
    {
        *isSufficient = false;
    }
    else
    {
        *isSufficient = true;
    }
    return ERROR_SUCCESS;
}

DWORD GetCenterChannelFrequencyOfLinkWithBestRSSI(GUID* interfaceGuid, ULONG* channelFrequency)
{
    wil::unique_wlan_handle clientHandle;
    DWORD maxClientVersion = 2;
    DWORD currentClientVersion = 0;
    DWORD result = WlanOpenHandle(maxClientVersion, nullptr, &currentClientVersion, &clientHandle);
    if (result != ERROR_SUCCESS) 
    {
        wprintf(L"WlanOpenHandle failed with error: %u\n", result);
        return result;
    }

    DWORD connectionQualitySize = 0;
    wil::unique_wlan_ptr<WLAN_REALTIME_CONNECTION_QUALITY> connectionQuality;
    result = WlanQueryInterface(
        clientHandle.get(), 
        interfaceGuid,
        wlan_intf_opcode_realtime_connection_quality,
        nullptr,
        &connectionQualitySize,
        wil::out_param_ptr<void**>(connectionQuality),
        nullptr);
    if (result != ERROR_SUCCESS) 
    {
        wprintf(L"WlanQueryInterface failed with error: %u\n", result);
        return result;
    }

    auto linkWithBestRssi = std::min_element(
        connectionQuality->linksInfo,
        connectionQuality->linksInfo + connectionQuality->ulNumLinks,
        [](const WLAN_REALTIME_CONNECTION_QUALITY_LINK_INFO& lhs, const WLAN_REALTIME_CONNECTION_QUALITY_LINK_INFO& rhs) {
            return lhs.lRssi > rhs.lRssi; // `Greater than` because RSSI is negative.
        });

    *channelFrequency = linkWithBestRssi->ulChannelCenterFrequencyMhz;
    return ERROR_SUCCESS;
}

規格需求

需求
標頭 wlanapi.h