🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #3234

Re: VB.NET: ip adres opvragen

#3234
From: Steven Van Dalem
Date: Wed, 21 Jan 2004 12:33
45 lines
2431 bytes
> Hoe kan ik in VB.NET het ip-adres opvragen van de pc waarop het progje
> draait ?

Untested:

Dim ipHostInfo As IPHostEntry = Dns.Resolve(Dns.GetHostName())
Dim ipAddress As IPAddress = ipHostInfo.AddressList(0)

of anders

imports System
imports System.Management

Public Class WMICardGrab
  Public Shared Sub Main()
    Dim query as ManagementObjectSearcher = new _
        ManagementObjectSearcher("SELECT * FROM
WIN32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'")
    Dim queryCollection as ManagementObjectCollection = query.Get()
    Dim mo as ManagementObject
    For Each mo In queryCollection
      Dim addresses() as string = CType(mo("IPAddress"), string())
      Dim defaultgateways() as string = CType(mo("DefaultIPGateway"),
string())

      Console.WriteLine("Network Card: {0}", mo("Description"))
      Console.WriteLine("    MAC Address: {0}", mo("MACAddress"))

      Dim ipaddress as string
      For Each ipaddress In addresses
         Console.WriteLine("    IP Address: {0}", ipaddress)
      Next

      Dim gateway as string
      For Each gateway In defaultgateways
        Console.WriteLine("    Gateway: {0}", gateway)
      Next
    Next
  End Sub
End Class

    To compile this you need to include the System.Management.dll
file.

Steven
Technical Details
Message-ID: <FkuPb.24$2A3.73801@phobos.telenet-ops.be>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!pop-news-1.colt-telecom.nl!newsgate.cistron.nl!aotearoa.belnet.be!news.belnet.be!ossa.telenet-ops.be!phobos.telenet-ops.be.POSTED!not-for-mail
References: <400d513c$0$322$ba620e4c@news.skynet.be>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fcea4,65e7986433bde550
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2004-01-21 04:33:41 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!pop-news-1.colt-telecom.nl!newsgate.cistron.nl!aotearoa.belnet.be!news.belnet.be!ossa.telenet-ops.be!phobos.telenet-ops.be.POSTED!not-for-mail
From: "Steven Van Dalem" <steven@ReMoVevandalem.be>
Newsgroups: be.comp.programming
References: <400d513c$0$322$ba620e4c@news.skynet.be>
Subject: Re: VB.NET: ip adres opvragen
Lines: 47
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <FkuPb.24$2A3.73801@phobos.telenet-ops.be>
Date: Wed, 21 Jan 2004 12:33:41 GMT
NNTP-Posting-Host: 213.118.199.140
X-Complaints-To: abuse@telenet.be
X-Trace: phobos.telenet-ops.be 1074688421 213.118.199.140 (Wed, 21 Jan 2004 13:33:41 MET)
NNTP-Posting-Date: Wed, 21 Jan 2004 13:33:41 MET
Organization: Telenet Internet