NIC Speed

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

How can I automatically detect the speed that my NIC is running at if
it is set to Auto Detect? If I swap between a 100 and 10 cable it will
correctly tell me what the connection speed is in the system tray, but
where can I programmatically get this info from. Has anyone got some
VB.NET code? I have seen some VB6 code at
http://vbnet.mvps.org/index.html?code/network/getinterfacetable.htm
but am not sure how to use this in VB.NET.

Cheers
 
Steve,

This code could all be translated into VB.NET with just a little work.

Some gotchas:
VB.NET of course has different data types. So a vb6 integer is now a short,
a vb6 long is now an integer, etc. So in all declares you will need to be
careful with this.

VB.NET doesn't need the SET keyword either.

If you are allowed to use that code, copy it and modify it for .NET and it
looks like it will tell you.

I would have thought system.net would have something like this or even the
environment class but I didn't find anything.

Sorry I don't know more.

Shane
 
If you look you will see that this message had been posted to both the
winapi and vb.net groups. The reason for this being that the vb code
uses winapi to get the info which I am after.
 
Steve,

Good question, didn't notice that.
http://www.mentalis.org/vbtutor/vbdotnet.shtml
says you can't use as Any

http://www.dotnet247.com/247reference/msgs/4/22924.aspx speaks of As Any

I really don't know Steve,
Seems from reading these that you must pick some type, and have some idea
what type of data will be held there.
One person suggested using StringBuilder in the place of as any in some
instances, but not being familiar with the API call you are wanting I have
no clue.

Sorry.

Does anyone else know of a non API way to get the speed of the NIC card? Or
a registry entry?

Shane
 
Usually you can use the Object type (but not always)...

(e-mail address removed) (Steve) wrote in
 
(e-mail address removed) (Steve) wrote in
How can I automatically detect the speed that my NIC is running at if
it is set to Auto Detect? If I swap between a 100 and 10 cable it will
correctly tell me what the connection speed is in the system tray, but
where can I programmatically get this info from. Has anyone got some
VB.NET code? I have seen some VB6 code at
http://vbnet.mvps.org/index.html?code/network/getinterfacetable.htm
but am not sure how to use this in VB.NET.

Cheers

What about getting it from WMI? I haven't looked to see if that's in
there, but I would imagine that it is...

cw
 
Hi,

The speed isnt always available from the wmi. Add a reference to
system.management

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_NetworkAdapter where AdapterTypeID = 0")

Trace.WriteLine("Network Adapter")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strOut As String

Dim bAuto As Boolean = mo("AutoSense")

If bAuto Then

strout = String.Format("{0} - Speed {1}", mo("Name").ToString,
mo("Speed").ToString)

Else

strOut = String.Format("{0} - Speed Unavailable", mo("Name").ToString)

End If

Trace.WriteLine(strOut)

Next



Ken

------------------------
 
Back
Top