|
-
Feb 26th, 2009, 11:59 AM
#1
Thread Starter
New Member
Finding IP details
Hi all,
I'm trying to write a small app that finds the local machine's IP address (and SNM, DefGW, 1st DNS server, etc) then displays this nicely.
I don't want to go down the route of doing a Shell "ipconfig /all > somefile" then reading it in as I *know* this can be done another way.
I'm using VB 2008 Express Edition.
Any suggestions?
Cheers.
Grant.
-
Feb 26th, 2009, 12:29 PM
#2
Re: Finding IP details
Have a look at System.Net.NetworkInformation namespace. Do a search on this forum for examples...
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Feb 26th, 2009, 02:24 PM
#3
-
Feb 26th, 2009, 02:49 PM
#4
-
Feb 27th, 2009, 05:56 AM
#5
Thread Starter
New Member
Re: Finding IP details
 Originally Posted by Bulldog
Code:
Dim IpAddr() As Net.IPAddress = GetHostEntry(GetHostName()).AddressList
For i As Integer = 0 To IpAddr.Length - 1
MessageBox.Show(IpAddr(i).ToString)
Next
I put this in my Form_Load and all that happens, even before trying to run it, is that GetHostEntry(GetHostName part gets underlined in blue with the errors "GetHostEntry" and "GetHostName" not declared.
I'm guessing it's something to do with the missing "Using Imports System.Net.dns at the top of your file" part, but I don't know where to put the "Using Imports System.Net.dns" statement.
-
Feb 27th, 2009, 05:58 AM
#6
Thread Starter
New Member
Re: Finding IP details
 Originally Posted by dbasnett
look at my signature.
I'm guessing you're referring to the the link that goes here? If so, where ought I to be putting this code and how can I use it?
-
Feb 27th, 2009, 06:00 AM
#7
Re: Finding IP details
You put it at the very top of the file you are using it in.
Ie.
System.Net.dns
Public Form MyForm
However, you can add an imports at the project level so all objects can access it. See Project->Properties->References tab.
-
Feb 27th, 2009, 06:22 AM
#8
Thread Starter
New Member
Re: Finding IP details
 Originally Posted by Grimfort
You put it at the very top of the file you are using it in.
Ie.
System.Net.dns
Public Form MyForm
However, you can add an imports at the project level so all objects can access it. See Project->Properties->References tab.
Thank you! That's helped enormously. How would I get things like the Subnet Mask, Default Gateway & DNS? I'm playing around with the code now, but not getting anywhere fast.
Next issue... this works on XP nicely... Vista, however, comes up with a security policy warning:
Application attempted to perform an operation not allowed by the security policy. To grant this application the required permission, contact your system administrator, or use the Microsoft .NET Framework Configuration Tool.
If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately.
Request for the permission of type 'System.Net.DnsPermission. System.Version=2.0.0.0, Culture=neutral, PublicKey Token=b77a5c561934e089' failed.
Last edited by Thymox; Feb 27th, 2009 at 06:42 AM.
-
Feb 27th, 2009, 06:42 AM
#9
Re: Finding IP details
With Vista you have to run VS with admin rights, even if you are an admin. Right-click the vs icon, run as administrator.
However, this may not be the issue, it could be that you are trying to run the application from a network share to test it, .Net apps have to be given permission to do this, just copy it locally if this is the case.
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
|