【问题标题】:WlanQueryInterface data enumerationWlanQueryInterface 数据枚举
【发布时间】:2017-03-10 10:06:37
【问题描述】:

我想使用WlanQueryInterface 函数获取wlan_intf_opcode_bss_type

我的代码:

PDOT11_BSS_TYPE wlanInterfaceState = NULL;
DWORD wlanInterfaceStateSize = sizeof(wlanInterfaceState);
DWORD interfaceStateResult;
interfaceStateResult = WlanQueryInterface(hClient, &pIfInfo->InterfaceGuid, wlan_intf_opcode_bss_type, NULL, &wlanInterfaceStateSize, (PVOID *)&wlanInterfaceState, NULL);

if (interfaceStateResult != ERROR_SUCCESS) {
  qDebug() << "Error";
} else {
  qDebug() << wlanInterfaceState;
}

我得到十六进制值。当我使用 switch 枚举 wlanInterfaceState 时出现错误:

error: C2450: switch expression of type 'PDOT11_BSS_TYPE' is illegal

更新: DOT11_BSS_TYPE MSDN 中的枚举语法:

typedef enum _DOT11_BSS_TYPE { 
  dot11_BSS_type_infrastructure  = 1,
  dot11_BSS_type_independent     = 2,
  dot11_BSS_type_any             = 3
} DOT11_BSS_TYPE, *PDOT11_BSS_TYPE;

如何在wlanInterfaceState 上使用这些枚举? 谢谢。

【问题讨论】:

  • 即使您使用的是 qt,这也不是 Qt 的问题。你应该删除这个标签。
  • 我的建议。尝试使用 QTextStream 而不是 QDebug。看看 -> here
  • 我使用 qDebug() 只是为了测试目的。我想在 QLabel(setText 函数)中显示实际数据。

标签: c++ windows-applications wlanapi


【解决方案1】:

问题是我使用了指针wlanInterfaceState 版本,所以将它与switch一起使用不被认为是正确的表达方式。

切换(条件)语句

条件 - 整数或枚举类型的任何表达式,或上下文隐式可转换为整数或枚举类型的类类型,或使用大括号或等号初始化器声明此类类型的单个非数组变量。

既然它指向枚举,那么我需要取消引用它。

所以 switch 语句应该是这样的:

 switch (*wlanInterfaceState) {
         case dot11_BSS_type_infrastructure:
              qDebug() << "Infastructure";
         break;

         case dot11_BSS_type_independent:
              qDebug() << "Independent";
         break;

         case dot11_BSS_type_any:
              qDebug() << "Any";
         break;

         default:
              qDebug() << "Unknown";
         }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多