Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-19-2004, 12:43 PM   #1
Registered: Apr 2003
Posts: 178

Rep: Reputation: 30
Obtaining a default gateway IP address from a Win2K workstation

Obtaining a default gateway IP address from a Win2K workstation
using Visual Basic 5.0


Visual Basic 5.0

How do you Obtain a default gateway IP address from a Win2K workstation ?

1) I tried with OCX Winsock but it only have LocalIP property method not the method to obtain a default gateway.

2) The API GetIpForwardTable will allowed you to access a default gateway IP address, but I have not found the code example for it. Below is a C code. Maybe somebody could translate that to VB

Local_IP = Winsock1.LocalIP

#include <iphlpapi.h>

BOOL YourClass::CheckConnection()
  DWORD			dwTableSize = 0;
  BOOL			bHasDefaultRoute = FALSE;

  GetIpForwardTable(NULL, &dwTableSize, FALSE);
  pft = (MIB_IPFORWARDTABLE*) new BYTE[dwTableSize];

  if (GetIpForwardTable(pft, 
                        TRUE) == NO_ERROR)
    for (unsigned int nIndex = 0; 
             nIndex < pft->dwNumEntries;
      if (pft->table[nIndex].dwForwardDest == 0)
      // Default route to gateway
        bHasDefaultRoute = TRUE;

  delete pft;

  return bHasDefaultRoute;
Old 02-20-2004, 02:55 AM   #2
Registered: Feb 2004
Location: Vienna/Austria
Distribution: Debian Unstable
Posts: 36

Rep: Reputation: 15
Ähm... Maybe this is the wrong Forum for you... :-)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set the ip address for eth0, eth1 and the default gateway? abefroman SUSE / openSUSE 5 05-19-2005 04:15 AM
Obtaining IP LAN gateway in C under Linux executive Programming 2 04-13-2005 11:21 AM
Universal default gateway address resolution otisthegbs Linux - Networking 2 07-09-2004 02:28 AM
How do I get iptables to redirect my default gateway address? Paul Woodhouse Linux - Networking 3 11-11-2003 08:52 AM
odd default gateway address, uses addr ~.ip.~ whatzat? piratebiter Linux - Networking 0 09-07-2003 07:06 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration