Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Snippet] Get Local Getway
#1
Gets the local gateway
Usage: MsgBox(localgateway)

Code:
Function localgateway() As String
        Dim NetworkAdapters() As NetworkInterface = NetworkInterface.GetAllNetworkInterfaces
        Dim myAdapterProps As IPInterfaceProperties = Nothing
        Dim myGateways As GatewayIPAddressInformationCollection = Nothing

        For Each adapter As NetworkInterface In NetworkAdapters
            myAdapterProps = adapter.GetIPProperties
            myGateways = myAdapterProps.GatewayAddresses
            For Each Gateway As GatewayIPAddressInformation In myGateways
                If Not Gateway.Address.ToString = "0.0.0.0" Then
                    Return (Gateway.Address.ToString)
                Else
                    Return ("0.0.0.0")
                End If
            Next
        Next
    End Function
USB Anti-virus? Try USB Drive Defender
[Image: 8bQCusS.jpg]
Reply


Messages In This Thread
[Snippet] Get Local Getway - by euverve - 05-15-2011, 06:15 PM
RE: [Snippet] Get Local Getway - by KoBE - 05-16-2011, 07:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [VB.Net] Local/Remote TCP info from process [Source] The-One 5 4,120 08-11-2012, 05:18 PM
Last Post: Kenneth
  [Snippet] Autoclose Msgbox euverve 7 3,281 05-25-2011, 06:41 PM
Last Post: Pyratepig
  [Snippet] Check Email if gmail and valid password length euverve 4 1,804 05-20-2011, 06:51 AM
Last Post: stephen5565
  [Snippet] Get OS Uptime euverve 0 875 05-12-2011, 07:08 PM
Last Post: euverve
  [Snippet] Random pick from list (Range) euverve 0 689 05-12-2011, 08:22 AM
Last Post: euverve

Forum Jump:


Users browsing this thread: 2 Guest(s)