windows通过PDH获取网卡流量
程序员文章站
2022-06-03 08:38:58
...
char szCounterPath[500];
snprintf(szCounterPath, sizeof(szCounterPath)-1,
"\\Network Interface(%s)\\Bytes Received/sec", (const char*)inter->m_interface);
WCHAR szCounterPathW[500];
UTF8ToUnicode(szCounterPath, szCounterPathW, sizeof(szCounterPathW) / sizeof(WCHAR));
status = PdhAddCounterW(query, szCounterPathW, NULL, &(inter->m_counterReceived));
if (status != ERROR_SUCCESS)
{
inter->m_bBad = TRUE;
continue;
}
下一篇: Linux静态链接