gpt4 book ai didi

c++ - PacketReceived/Sec 值非常高

转载 作者:行者123 更新时间:2023-11-30 04:11:28 26 4
gpt4 key购买 nike

class Win32_PerfRawData_Tcpip_NetworkInterface : Win32_PerfRawData
{
uint32 BytesReceivedPerSec;
uint32 BytesSentPerSec;
uint64 BytesTotalPerSec;
string Caption;
uint32 CurrentBandwidth;
string Description;
uint64 Frequency_Object;
uint64 Frequency_PerfTime;
uint64 Frequency_Sys100NS;
string Name;
uint32 OutputQueueLength;
uint32 PacketsOutboundDiscarded;
uint32 PacketsOutboundErrors;
uint32 PacketsPerSec;
uint32 PacketsReceivedDiscarded;
uint32 PacketsReceivedErrors;
uint32 PacketsReceivedNonUnicastPerSec;
uint32 PacketsReceivedPerSec;
uint32 PacketsReceivedUnicastPerSec;
uint32 PacketsReceivedUnknown;
uint32 PacketsSentNonUnicastPerSec;
uint32 PacketsSentPerSec;
uint32 PacketsSentUnicastPerSec;
uint64 Timestamp_Object;
uint64 Timestamp_PerfTime;
uint64 Timestamp_Sys100NS;
};

这个 WMI 类。

我得到 PacketReceived/sec 但它的值高于 120000。我认为它每秒接收的字节数。我得到了其他值及其正确

int WMIClass::ExcuteQuery(const char* cstr,LPWSTR atrb)
{
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t(cstr),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);

while (pEnumerator)
{
hres = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtProp;

// Get the value of the Name property
hres = pclsObj->Get(atrb, 0, &vtProp, 0, 0);

intVal=vtProp.uintVal;
}
return intVal;
}

程序正常执行并且可以轻松读取值,但我对这个值有疑问。我需要在网络适配器上每秒收到的数据包。任何简单的解决方案?如果在 Qt 框架中,将不胜感激。

最佳答案

确保正确初始化 intVal:

int WMIClass::ExcuteQuery(const char* cstr,LPWSTR atrb) {
int intVal = 0;

hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t(cstr),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);

while (pEnumerator) {
hres = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);

if(0 == uReturn)
break;

VARIANT vtProp;

// Get the value of the Name property
hres = pclsObj->Get(atrb, 0, &vtProp, 0, 0);

intVal = vtProp.uintVal;
}

return intVal;
}

关于c++ - PacketReceived/Sec 值非常高,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20225921/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com