🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: be.comp.programming
3 messages
3 total messages Started by Snuyt Tue, 20 Jan 2004 16:03
VB.NET: ip adres opvragen
#3231
Author: Snuyt
Date: Tue, 20 Jan 2004 16:03
7 lines
1019 bytes
Hallo,

Hoe kan ik in VB.NET het ip-adres opvragen van de pc waarop het progje 
draait ?

	bedankt,
		Snuyt
Re: VB.NET: ip adres opvragen
#3233
Author: Pieter Philippaerts
Date: Wed, 21 Jan 2004 04:59
9 lines
1444 bytes
"Snuyt" <snuyt_nospam@skynet.be> wrote in message
> Hoe kan ik in VB.NET het ip-adres opvragen van de pc waarop het progje
> draait ?

De hostname van de computer waarop je werkt resolven. Iets in de aard van:
 Dim he as IPHostEntry =  Dns.Resolve(Dns.GetHostName())

Mvg,
Pieter Philippaerts
Re: VB.NET: ip adres opvragen
#3234
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads