|
-
Feb 20th, 2006, 09:27 AM
#1
Thread Starter
Hyperactive Member
Getting adapter IP address....
I'm writing a small app that displays various computer info.
One of the sections is the network, I currently have it showing the adapter name, link status, mac address and speed.
What I want to do is show the ip address of the adapter as well, the problem is that the NetworkInformation class seems to provied everything but this...
I've tried the System.Net.IPHostEntry and retrived the IpAddressCollection but how do I identify which adapter has which IP address ?
Thanks in advance.
*edit: I'm using vs2005
-
Feb 20th, 2006, 03:47 PM
#2
Re: Getting adapter IP address....
there is some code on this page that shows how to change the IPAddy. Maybe you can tweak it to to get what you want....
kevin
Process control doesn't give you good quality, it gives you consistent quality.
Good quality comes from consistently doing the right things.
Vague general questions have vague general answers. A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.
______________________________ Last edited by kebo : Now. Reason: superfluous typo's
-
Feb 21st, 2006, 03:11 AM
#3
Thread Starter
Hyperactive Member
Re: Getting adapter IP address....
Thanks, I'll have a look into that. I'd have hoped they just had a method that returned the ip address of the adapter but suppose you can't have everything
-
Feb 21st, 2006, 03:36 AM
#4
Member
Re: Getting adapter IP address....
Hi
Here's something rough and ready for getting the information. This is a function I wrote that gets output from a command screen:
private string GetProcessString(string process, string args)
{
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.UseShellExecute = false;
psi.FileName = process;
psi.Arguments = args;
psi.RedirectStandardOutput = true;
System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
string s = p.StandardOutput.ReadToEnd();
p.StandardOutput.Close();
return s;
}
Now call ipconfig from the command window:
GetProcessString("ipconfig", @"/all")
You'll get the output from ipconfig in a string. You can go through this, parsing out all of the details of the various network connections.
Hope this helps
Chris Seary
-
May 5th, 2006, 06:02 AM
#5
New Member
Re: Getting adapter IP address....
What about this? This gets the current active ip address.
VB Code:
Sub
Dim IpAddr As IPAddress() = ipEntry.AddressList
TextBox1.Text = " " + IpAddr(0).ToString()
End Sub
And the adapter info you can get from the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Adapters
-
May 6th, 2006, 11:52 PM
#6
Re: Getting adapter IP address....
I had addressed this a while ago in another thread that can get it using WMI. Check out the full example in post #6 of the thread below:
http://www.vbforums.com/showthread.php?t=397835
You can also check out the WMI codebank submission for some general ways of using it, as you can gather all sorts of system info.
<ADVERTISEMENT>MySystemSpy, also in my sig, was a prog that solely uses WMI to gather loads of info about the system, if you care to check it out (its freeeeee ) </ADVERTISEMENT>
Last edited by gigemboy; May 6th, 2006 at 11:56 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|