Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1116071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:14:56+00:00 2026-05-17T03:14:56+00:00

If you go to Start and click Computer and then click on the Network

  • 0

If you go to Start and click Computer and then click on the Network link on the left hand side, you’ll notice on the right hand side several categories, one of which is titled "Network Infrastructure", in that category, my router is listed, and in my case, it is "LINKSYS WAG160N Wireless-N ADSL2+ Gateway" and when you right-click and select properties, it lists basic info such as internal/gateway IP address, on mine it is "192.168.1.1"

I would like to know how to retrieve this information in code, preferably a Windows API so that I can call it using a legacy VB6 app. Also, even if you just know a .NET version or a Delphi version, please do list that as well as I can code in both. However, the answer I’m ultimately seeking is a method to access this via VB6 so that would probably be a WinAPI call, however, other methods are also welcome in case I can’t find a legacy method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T03:14:57+00:00Added an answer on May 17, 2026 at 3:14 am

    There is a bit more code required than I’d like. If there is a more compact approach I’d be interested myself.

    As I understand this, Windows gets the information via UPnP. UPnP works as a sort of Web Service over UDP. It has quirks because it uses UDP multicasts so it can be dificult to code explicitly, but Windows offers a helper library. This library is not “wrapped” well for use from a VB6 program, but with a few tricks you can get access to most of its functionality.

    The sample below is written so that it can compile on Win XP as well as later versions of Windows. The Win XP version of the library lacks critical typelib info that prevents VB6 from using everything it offers. This was corrected in Vista, however for this application we don’t need the full callback capabilities it offers. You could use an external typelib if you needed full access, or you can compile on Vista or later. A progam compiled on Vista works fine on XP.

    The code below is abstracted from a larger Class I use for UPnP NAT port mapping in VB6 servers. This subset may do what you require though.

    UPnPNAT.cls

    Option Explicit
    'Requires reference to:
    '
    '   UPnP 1.0 Type Library (Control Point)
    '
    
    Private Const CONN_SVCTYPEID_URI As String = "urn:schemas-upnp-org:service:WANIPConnection:1"
    Private Const CONN_ID_URI As String = "urn:upnp-org:serviceId:WANIPConn1"
    
    Private UDFinder As UPNPLib.UPnPDeviceFinder
    Private WithEvents UNCBs As UPnPNATCBs
    Private findData As Long
    Private blnSuccess As Boolean
    
    Public Event Result(ByVal Success As Boolean, ByVal FriendlyName As String, ByVal IP As String)
    
    Public Sub Fetch()
        blnSuccess = False
        Set UDFinder = New UPNPLib.UPnPDeviceFinder
        Set UNCBs = New UPnPNATCBs
        findData = CallByName(UDFinder, "CreateAsyncFind", VbMethod, CONN_SVCTYPEID_URI, 0, UNCBs)
        UDFinder.StartAsyncFind findData
    End Sub
    
    Private Sub UNCBs_DeviceAdded(ByVal Device As UPNPLib.IUPnPDevice)
        Dim Services As UPNPLib.UPnPServices
        Dim Service As UPNPLib.UPnPService
        Dim varInActionArgs, varOutActionArgs
        Dim strFriendlyName As String
        Dim strIP As String
    
        strFriendlyName = Device.FriendlyName
        On Error Resume Next
        Set Services = Device.Services
        If Err.Number = 0 Then
            On Error GoTo 0
            With Services
                If .Count > 0 Then
                    On Error Resume Next
                    Set Service = .Item(CONN_ID_URI)
                    If Err.Number = 0 Then
                        On Error GoTo 0
                        ReDim varInActionArgs(0 To 0)
                        ReDim varOutActionArgs(0 To 0)
                        Service.InvokeAction "GetExternalIPAddress", _
                                             varInActionArgs, _
                                             varOutActionArgs
                        strIP = varOutActionArgs(0)
                        blnSuccess = True
                    Else
                        On Error GoTo 0
                    End If
                End If
            End With
        Else
            On Error GoTo 0
        End If
    
        UDFinder.CancelAsyncFind findData
        RaiseEvent Result(blnSuccess, strFriendlyName, strIP)
        Set UDFinder = Nothing
        Set UNCBs = Nothing
    End Sub
    
    Private Sub UNCBs_SearchComplete()
        If Not blnSuccess Then
            RaiseEvent Result(False, "", "")
        End If
    End Sub
    

    UPnPNATCBs.cls

    Option Explicit
    
    Public Event DeviceAdded(ByVal Device As UPNPLib.IUPnPDevice)
    Public Event DeviceRemoved(ByVal UDN As String)
    Public Event SearchComplete()
    
    Public Sub IDispatchCallback( _
        ByVal pDevice As Variant, _
        ByVal bstrUDN As Variant, _
        ByVal lType As Variant)
        'NOTE: Must be dispID = 0, i.e. the default method of the class.
    
        Select Case lType
            Case 0
                RaiseEvent DeviceAdded(pDevice)
            Case 1
                RaiseEvent DeviceRemoved(bstrUDN)
            Case 2
                RaiseEvent SearchComplete
        End Select
    End Sub
    

    Form1.frm

    Option Explicit
    
    Private WithEvents UN As UPnPNAT
    
    Private Sub Form_Load()
        Set UN = New UPnPNAT
        lblStatus.Caption = "Searching..."
        UN.Fetch
    End Sub
    
    Private Sub UN_Result(ByVal Success As Boolean, ByVal FriendlyName As String, ByVal IP As String)
        If Success Then
            lblStatus.Caption = FriendlyName & " " & IP
        Else
            lblStatus.Caption = "Failed"
        End If
    End Sub
    

    You may have to tweak this some if you have multiple UPnP devices providing connections in your network.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

By following: Start -> Computer -> Right Click -> Properties -> Advanced System Settings
I want to allow the user to click a start point and then click
When I start a drag and drop using a right click in WPF it
The interactive debugger works fine on one computer. But on another, which I configured
I have a webpage that, when you click start patrolling, starts counting the time
When I click on Start the stopWatchLabel shows the following (its static, nothings runs):
I have function Start() that is fired on ready. When I click on .ExampleClick
On a page i have a flash file. I click it once to start
When we start getting into algorithm design and more discrete computer science topics, we
I am working on a software[runs on a public computer] which helps to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.