Connecting Tech Pros Worldwide Help | Site Map

how to get IP address without using DNS

  #1  
Old June 18th, 2006, 08:25 AM
crespo
Guest
 
Posts: n/a
hi,Everybody.
I want to get my computer's local IP address,I search internet for some
help,but most of them suggests using DNS with
codes like these:
IPHostEntry ihe = Dns.GetHostByName(Dns.GetHostName());
IPAddress myself = ihe.AddressList[0];

But I don't want to use DNS,Could anyone help me? Any suggestions will be
really appreciated.

Best regards

Crespo

2006-06-18




  #2  
Old June 18th, 2006, 01:55 PM
Nicholas Paldino [.NET/C# MVP]
Guest
 
Posts: n/a

re: how to get IP address without using DNS


Crespo,

I would use the classes in the System.Management namespace to get the
information from the OS itself, not do a lookup.

You can look for instances of the Win32_NetworkAdapterConfiguration for
the network card you want to work with, and then get the IPAddress property
which is an array of the IP addresses that are associated with the network
adapter.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"crespo" <wuhuanfa@21cn.com> wrote in message
news:%23fl6JjqkGHA.4660@TK2MSFTNGP05.phx.gbl...[color=blue]
> hi,Everybody.
> I want to get my computer's local IP address,I search internet for some
> help,but most of them suggests using DNS with
> codes like these:
> IPHostEntry ihe = Dns.GetHostByName(Dns.GetHostName());
> IPAddress myself = ihe.AddressList[0];
>
> But I don't want to use DNS,Could anyone help me? Any suggestions will be
> really appreciated.
>
> Best regards
>
> Crespo
>
> 2006-06-18
>
>
>
>[/color]


  #3  
Old June 20th, 2006, 12:35 PM
Crespo
Guest
 
Posts: n/a

re: how to get IP address without using DNS


Thank you,Nicholas Paldino.
I have tried your advice and it sucessfully works. Thanks again.

Crespo
"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> дÈëÏûÏ¢
news:OufwCbtkGHA.1260@TK2MSFTNGP05.phx.gbl...
Crespo,

I would use the classes in the System.Management namespace to get the
information from the OS itself, not do a lookup.

You can look for instances of the Win32_NetworkAdapterConfiguration for
the network card you want to work with, and then get the IPAddress property
which is an array of the IP addresses that are associated with the network
adapter.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"crespo" <wuhuanfa@21cn.com> wrote in message
news:%23fl6JjqkGHA.4660@TK2MSFTNGP05.phx.gbl...[color=blue]
> hi,Everybody.
> I want to get my computer's local IP address,I search internet for some
> help,but most of them suggests using DNS with
> codes like these:
> IPHostEntry ihe = Dns.GetHostByName(Dns.GetHostName());
> IPAddress myself = ihe.AddressList[0];
>
> But I don't want to use DNS,Could anyone help me? Any suggestions will be
> really appreciated.
>
> Best regards
>
> Crespo
>
> 2006-06-18
>
>
>
>[/color]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get the IP address of a website without using DNS anything? econobeing answers 7 November 16th, 2005 07:31 PM
send email using c# without using CDONTS Mohammed Abdel-Razzak answers 11 November 16th, 2005 04:53 AM
How to get my own IP address without DNS Kazu answers 6 July 23rd, 2005 06:01 AM
How to lunch webpage without using SMTP server? Nancy answers 21 July 18th, 2005 02:06 PM