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 /秒值非常高
我得到PacketReceived /秒,但它的值高於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;
}
計劃excutes正常和值可以輕鬆地閱讀,但我懷疑這個值。 我需要在網絡適配器上每秒接收數據包。 任何簡單的解決方案?如果在Qt框架中,將不勝感激。
我看不到'intVal'被初始化的位置,如果它是一個成員變量,你可能正在運行一個前面的值被返回或返回未初始化內存的值。在你的代碼中,你應該處理'Get'操作失敗,無論是來自未知屬性名稱還是其他失敗;如果失敗,你應該返回一個錯誤值或拋出和異常。 – joshperry