我想在RAM
中检测到WMI
制造商。我得到奇怪的符号而不是实际数据的问题。我也使用wmic
命令检查了它。屏幕截图如下所列。
截图:
我尝试过不同的方法在输出前检查值,但问题仍然存在。
代码:
VARIANT ramManufacturer;
pclsObj->Get(L"Manufacturer", 0, &ramManufacturer, 0, 0);
QString userRAMManufacturer;
QStringList ramProperty;
QStringList ramData;
if (SysStringLen(ramManufacturer.bstrVal) != 0) {
userRAMManufacturer = QString::fromWCharArray(ramManufacturer.bstrVal);
if (!userRAMManufacturer.isEmpty()) {
ramProperty << QObject::tr("Manufacturer");
ramData << userRAMManufacturer;
}
}
或者
if (CComBSTR(ramManufacturer.bstrVal).Length() != 0) {
userRAMManufacturer = QString::fromWCharArray(ramManufacturer.bstrVal);
if (!userRAMManufacturer.isEmpty()) {
ramProperty << QObject::tr("Manufacturer");
ramData << userRAMManufacturer;
}
}
如何解决此问题?提前谢谢。
答案 0 :(得分:0)
@selbie
谢谢。我已检查Get
值,现在值正确。
<强>代码:强>
if (ramManufacturer.vt != VT_NULL && ramManufacturer.vt == VT_BSTR) {
userRAMManufacturer = QString::fromWCharArray(ramManufacturer.bstrVal);
ramProperty << QObject::tr("Manufacturer");
ramData << userRAMManufacturer;
}