欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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;
            }