Upload an image first.
Implementation Method:
ThisProgramWMI is used to dynamically obtain data in WMI. And the calculated results are displayed on the interface.
The main WMI classes used are win32_perfrawdata_tcpip_networkinterface and win32_networkadapter.
First, use win32_networkadapter to obtain the names of all network adapters in the computer. After selecting different names, you can dynamically obtain the underlying information.
The method for obtaining an adapter on a computer is as follows:
Ilist <win32_networkadapter> networditems = NULL;
Networkadapter NA = NULL;
NA = new networkadapter (computername );
Networditems = Na. selectall ();
Foreach (win32_networkadapter item in networditems)
{
String S = item. adaptertype;
If (s! = NULL)
{
If (item. servicename = "pptpminiport ")
{
Continue;
}
Upnetitems (item. netconnectionid, item. Name );
}
}
Main Computing speedAlgorithmAs follows:
PNI. m_where = "where name = '" + Result + "'";
Netlist. Clear ();
Netlist = PNI. selectall ();
Win32_perfrawdata_tcpip_networkinterface item = netlist [0] As win32_perfrawdata_tcpip_networkinterface;
Float countervalue1 = (float) item. bytesreceivedpersec;
Float upv1 = (float) item. bytessentpersec;
Float timevaluee1 = (float) item. timestamp_perftime;
Float timebase = (float) item. frequency_perftime;
System. Threading. thread. Sleep (500 );
Netlist. Clear ();
Netlist = PNI. selectall ();
Item = netlist [0] As win32_perfrawdata_tcpip_networkinterface;
Float countervalue2 = (float) item. bytesreceivedpersec;
Float upv2 = (float) item. bytessentpersec;
Float timevalue2 = (float) item. timestamp_perftime;
If (timevalue2-timevalue1 = 0)
{}
Else
{
Float downs = (countervalue2-countervalue1)/(timevalue2-timevalue1)/timebase)/1024;
Float up = (upv2-upv1)/(timevalue2-timevalue1)/timebase)/1024;
Updatavalue (downs );
Updatavalue2 (up );
}
This program uses an easywmi DLL, which includes all WMI definitions. You can search for and download the code from codeproject.
WMI is very powerful, and information on almost all computers can be found through this. It is easy to develop performance monitoring programs. In the future, you will have time to write a program that uses WMI for computer monitoring and management.
However, I have been busy writing a com program with UI EXE using VC recently. There may be no time in the recent period.
Very late, sleeping
Corresponding controls: http://www.codeproject.com/Articles/17564/Simple-Performance-Chart