?
Solved

Getting Network Interface Name using IP Helper or similar library

Posted on 2003-03-23
17
Medium Priority
?
2,355 Views
Last Modified: 2013-12-03
I am trying to get the "friendly" interface names for the network interfaces on a windows machine.  What I need is exactly the list of names that are in the "Network and Dial-up Connections" control panel.  I have tried getting the information from the IP_ADAPTER_INFO and MIB_IFROW structures but neither of these provide the name I need.  I can get at the name of the physical device but not the "friendly" name.  There is a field in the MIB_IFROW that doesn't seem to work properly that may be exactly what I'm looking for.  It is the MIB_IFROW.wszName field.  I always get this field always containing 0s, NULL value.  Is there some trick to using this?  I'm using windows 2000 but this also needs to run on XP and CE in the future.  Is there some other library similar to IP Helper that has a function in it to get this data that I should use?  Do I need to get the name differently for normal connections versus Dial up network connections, for example using MprXxx or RasXxx functions? PS, this is my first time on this site, what are the ways I can get more points.
0
Comment
Question by:brianbraunstein
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
17 Comments
 
LVL 49

Expert Comment

by:DanRollins
ID: 8189461
This open question shows an example of using RasEnumEntries()

    http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_20556648.html

It returns the RAS names.  On my system it returns "NetZero" and "MyTestConn" (exactly as in the Control Pnael), but does not return "Local Area Connection" or "Make new connection"

-- Dan
0
 

Author Comment

by:brianbraunstein
ID: 8190324
Thanks a bunch Dan.  I ran across that function and the RasEnumConnections(), which is useful for my specific purpose.  But the problem with both these functions is I cannot find a field in them that will map to the structures returned by GetAdaptersInfo() and GetIfTable().  In both of these functions the structure's returned, IP_ADAPTER_INFO and MIB_IFROW, have a field called Index or dwIndex, which is the index of the interface they correspond to.  Am I going to have to do some silly work around to achieve my goal, whic is to have a mapping between MIB_IFROW/IP_ADAPTER_INFO structures and RASCONN or RASENTRY structures.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8191490
You didn't mention it, so I have to ask: Did you check MIB_IFROW.bDescr ?  Often, the "description" is the text that is displayed to users.

You can get a list of the objects in the
       Control Panel/Network and Dial-up Connections
shell folder by using the

    IShellFolder::EnumObjects

Is that what you want?  Not knowing your actual goal (that is, *why* you want these names) hampers me in my research.

-- Dan
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:brianbraunstein
ID: 8191871
Thanks for all your help so far Dan.  I'm looking into the IShellFolder documentation right now.  I just wanted to post my goal.  Basically, if I need to figure out how to create something exactly like ipconfig.exe, because what I'm trying to do follows directly from that.  The ipconfig.exe example in the Platform SDK samples doesn't help because it doesn't retreive this "friendly" name.  The real ipconfig.exe will display the "friendly" name along with the ip addresses, gateways, etc.  Sorry for not stating that more clearly.
Thanks again!
0
 

Author Comment

by:brianbraunstein
ID: 8191983
I guess I should also say more boldly that I need something EXACTLY like ipconfig.  So it works with dial up networknig connections, ethernet connections, wireless, bluetooth (which uses dial up networking), etc.  I need to get the IP, gateway for all of these AS WELL AS THE INTERFACE INDEX, like in MIB_IFROW.dwIndex.  The MIB_IFROW.bDescr doesn't contain the "friendly" name I'm looking for.  I really wish it did!  One way I could do what I'm trying to do is get the RASENTRY structs from RasEnumEntries(), then map the MIB_IFROWs and IP_ADAPTER_INFOs to their corresponding RASENTRY structs using the IP Address fields in both.  This seems a bit inefficient to me though but I've been plugging away at this problem for a long long time so I may have to end up doing that.
Thanks.
0
 

Author Comment

by:brianbraunstein
ID: 8192265
The "inefficient workaround" that I mentioned above doesn't work.  I just tried it.  The RasGetEntryProperties function returns an RASENTRY struct.  The RASENTRY.ipaddr field in this is the ip address that you set for the connection if not using DHCP.  It is not the ip address the connection is currently using.  Bummer.  This is the most annoying problem ever!  Why doesn't microsoft provide the actual code for ipconfig.exe instead of a scaled down ipconfig?  Grrr!!!  Anyways, I hope you are having more luck than me.
Thanks,
Brian
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8192315
Where did you get the "scaled down" ipconfig source code.  That would give me a starting point.
-- Dan
0
 

Author Comment

by:brianbraunstein
ID: 8192516
If you have the microsoft platform sdk installed with samples the IPConfig sample is at Program Files\Microsoft SDK\Samples\netds\IPHelp\IPConfig   If you do not have this installed, which I imagine you totally do...but yeah if you don't I'll put it up on my server at
http://bristyle.com/IPConfigSample.zip

My latest attempts were to use GetAdaptersAddresses() function, which returns the IP_ADAPTERS_ADDRESSES struct.  But this didn't work because it's not supported on windows 2000 according to the SDK documentation.  And according to how it didn't work when I tried anyways in hopes that it would work.  If you help me figure this out, then if I had 5 bazillion points I'd so give them to you :) Too bad I don't since I just found out about this site.
Anyways...
Thanks,
Brian
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8193365
There is a clue... The actual IpConfig.exe (in my WinNT/system32 dir) may be calling an undocumented function
     NhGetInterfaceNameFromGuid
since it is exported from IPHLPAPI.Dll

I can't find out anything about this fn, but it certainly seems like a candidate as to how IpConfig.Exe is locating the "friendly name" that you seek.  It may be possible to figure out the parameters and returns for that fn...

Some other clues are in the MprAdminXxxxx API funcs in Routine and Remote Access Services.

I noticed that if you call RasGetEntryProperties after calling RasEnumeEntries, you can get back a GUID, but I can't make it match with anything.

=--=-==-=-=-=-=-=-=-=-=-=-=-
Since you brought up points... 75 is pretty low for such a complicated question.   I'm pretty sure that you can purchase additional points via this link:
    https://secure.experts-exchange.com/jsp/buyPoints.jsp
but I've never done it...

-- Dan
0
 

Author Comment

by:brianbraunstein
ID: 8199752
Looks like we're both stuck now. Dang it.  Fortunately I go to and work for UCSD, and apparently our computer science department is has a close relationship with Microsoft.  I'll talk to someone here and see if I can get ahold of the documentation on that function.
Thanks anyways,
Brian
0
 
LVL 9

Expert Comment

by:tkalchev
ID: 8223759
Maybe what are you looking for is located in the Registry under the key

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network

0
 

Author Comment

by:brianbraunstein
ID: 8226319
Thanks for the suggestion.  I've already been  through the registry a bunch.  I searched for each of the GUIDs that I could get from the IP Helper returned information.  There was no consistent location between normal network connections and RAS connections.  Plus the GUIDs I got from RasEnumConnections were not even in the registry at all, I believe these GUIDs are current-connection specific and therefor only stored in memory.  Thanks anyways though! What I've been trying to do is step through the disassembly of ipconfig.exe using the VC++ debugger.  This is incredibly painful.  Hopefully the people at UCSD will come through and be able to pull their strings at Microsoft for me.
Thanks again,
Brian Braunstein
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8226482
>>What I've been trying to do is step through the disassembly of ipconfig.exe using the VC++ debugger.
If you can find the call to
     NhGetInterfaceNameFromGuid
then it should be pretty straightforward to figure out the parameters.

-- Dan
0
 

Author Comment

by:brianbraunstein
ID: 8226868
I'm not the super hardcore genius that you are unfortunately.  Finding the call is pretty annoying for me, and once I do find it, I'm afraid it will be very difficult for me to figure out what is going on since assebly from a disassembler isn't exactly documented.  I was thinking maybe I could replace IPHlpApi.dll with my own version, put a variable argument for the parameter to the NhGetetc... function, and just print out 5 or 10 integers in hex assuming that the arguments were either pointers or 32 bit values of some sort.  Then from these hex value I could figure out what these things being passed are, heap memory, stack memory, a number, etc...  Then do printfs or MessageBoxs for the pointers assuming they are string pointers, then assuming integer pointers to see what they contain.  The only problem is it seems windows really really doesn't like having a messed up IpHlpApi.dll in there and it would be really annoying to export all the IP Helper functions.  I was thinking maybe I'll put my own fake dll and a copy of ipconfig.exe in a seperate folder and then maybe ipconfig.exe will use my fake dll instead of the system folder one, and my system doesn't get screwed up that way.  Either that or the CS department guess will get those Microsoft strings pulled for me before I have time to try that...lets hope for the second one.  I'LL BE SURE TO POST THE USAGE FOR THIS FUNCTION IF THEY GET IT FOR ME! MUHAHAH!
Brian Braunstein
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 10788565
PAQed, with points refunded (75)

Computer101
E-E Admin
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question