Solved

Getting the LAN Connection Speed 10 mbits  100 mbits, Half Duplex / Full duplex

Posted on 2004-10-19
4
1,189 Views
Last Modified: 2010-05-18
Does any one know how to get the Local area network connection speed?

I need to know if it is 10, 100 or 1000
and if it is Half duplex or Full duplex

Using Delphi 7, Windows 2000 pro

Cheers Darren
0
Comment
Question by:dhnkley
  • 2
4 Comments
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12355969
Interesting... I expected this information to be available through WMI but it isn't. Besides, you might be in trouble since there are some different network speeds available too. I once had an USB connection between two PC's and this was listed as only 5 mbit. My wireless network card claims it's 45 mbit most of the time. Still, I think you can get the performance data through WMI which should give you the bandwidth value and lots of other information.
0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 500 total points
ID: 12368063
I've done some search in WMI. You could use a 'select CurrentBandwidth, Name from Win32_PerfRawData_Tcpip_NetworkInterface' query in WMI to get the bandwidth per network controller. However, determining duplex mode is something I haven't found within WMI.

This code gets the bandwidth for all network cards:

uses
  Windows, SysUtils, Classes, ActiveX, ComObj, WbemScripting_TLB;

const
  sQuery = 'select CurrentBandwidth, Name from Win32_PerfRawData_Tcpip_NetworkInterface';
var
  Enum: IEnumVariant;
  Item: SWbemObject;
begin
  Enum := CoSWbemLocator.Create.ConnectServer( '', 'root\cimv2', '', '', '', '', 0, nil ).ExecQuery( sQuery, 'WQL', wbemFlagBidirectional, nil )._NewEnum as IEnumVariant;
  while NextItem( Enum, SWBemObject, Item ) do begin
    WriteLn( 'Network ', VarToStr( Item.Properties_.Item( 'Name', 0 ) ), ', bandwidth ', VarToStr( Item.Properties_.Item( 'CurrentBandwidth', 0 ) ) );
  end;
end;

WbemScripting_TLB is created by converting the C:\WINNT\system32\wbem\wbemdisp.tlb type library to Delphi. But for Delphi 7 I've already created a version at http://www.workshop-alex.org/Sources/WbemScripting_TLB.pas that can be used.
Now, all you need is the Duplex info. :-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question