Today, I saw how Windows can get traffic interfaces.

Source: Internet
Author: User

Now I will post the code first. Because it is too late, it is time to go to bed. I will study it tomorrow.

PMI-> table [I]. dwinoctets; indicates the download traffic.

PMI-> dwnumentries indicates the number of NICs on your machine, which is listed in the same order as the ipconfig/all command in the command prompt (CMD. Note that the third parameter of getiftable (PMI, & dwsize, true); is true.

The Code is as follows:

Mib_iftable * PMI;

PMI = (mib_iftable *) malloc (sizeof (mib_iftable ));
Ulong dwsize = sizeof (mib_iftable );

DWORD errcode = getiftable (PMI, & dwsize, true );
If (error_insufficient_buffer = errcode)
{
Free (PMI );
PMI = (mib_iftable *) malloc (dwsize );
}
Errcode = getiftable (PMI, & dwsize, true );
If (no_error! = Errcode)
{
Return;
}
For (INT I = 0; I <PMI-> dwnumentries; ++ I)
{
Int xxx = PMI-> table [I]. dwinoctets;
}

Return;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.