1. structure for GetAdaptersAddresses

Hi All,
I'm struggling with defining a structure (using win32lib) for
  GetAdaptersAddresses.. I need this to get the 'friendly name' for Network
  adapters. The structure is

typedef struct _IP_ADAPTER_ADDRESSES {
   union {                                              
       ULONGLONG Alignment;                             
       struct {                                         
           ULONG Length;                                
           DWORD IfIndex;                               
       };                                               
   };                                                   
   struct _IP_ADAPTER_ADDRESSES *Next;                  
   PCHAR AdapterName;                                   
   PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress;     
   PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress;     
   PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress; 
   PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress;
   PWCHAR DnsSuffix;                                    
   PWCHAR Description;                                  
   PWCHAR FriendlyName;                                 
   BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];    
   DWORD PhysicalAddressLength;                         
   DWORD Flags;                                         
   DWORD Mtu;                                           
   DWORD IfType;                                        
   IF_OPER_STATUS OperStatus;                           
   DWORD Ipv6IfIndex;                                   
   DWORD ZoneIndices[16];                               
   PIP_ADAPTER_PREFIX FirstPrefix;                      
} IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES;   

So far I have...
constant
  MAX_ADAPTER_ADDRESS_LENGTH     = 8 ,
  char_    = #01000001,
-- typedef struct _IP_ADAPTER_ADDRESSES {  
-- 	union {    ULONGLONG Alignment;  		  
-- 	struct {      
-- 		ULONG Length;     					 
-- 		DWORD IfIndex;    };  };  				
  IP_ADAPTER_ADDRESSES_Next	= w32allot(Ptr),  
  AdapterName			= w32allot(char), 
  PIP_ADAPTER_UNICAST_ADDRESS 	= w32allot(Ptr), 
  PIP_ADAPTER_ANYCAST_ADDRESS 	= w32allot(Ptr),
  PIP_ADAPTER_MULTICAST_ADDRESS = w32allot(Ptr), 
  PIP_ADAPTER_DNS_SERVER_ADDRESS= w32allot(Ptr), 
  DnsSuffix		        = w32allot(char_*2),
  IP_Description	        = w32allot(char_*2),  
  FriendlyName		        = w32allot(char_*2), "
  PhysicalAddress	= w32allot({MAX_ADAPTER_ADDRESS_LENGTH, Byte}),  
  PhysicalAddressLength	       = w32allot(DWord),	
  Flags			       = w32allot(DWord),  
  Mtu			       = w32allot(DWord), 
  IfType		       = w32allot(DWord),	
-- 		IF_OPER_STATUS OperStatus;  
  Ipv6IfIndex		       = w32allot(DWord),  
  ZoneIndices		       = w32allot(16, DWord),  
  PIP_ADAPTER_PREFIX 	       = w32allot(Ptr)

Assuming (*big* assumption, probably wrong!) that the ones already defined are
  correct, the commented ones are my problems...

 Help anyone? please!

PeteS

new topic     » topic index » view message » categorize

2. Re: structure for GetAdaptersAddresses

Pete Stoner wrote:
> 
>  Help anyone? please!
> 
> PeteS

Check:

http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=getadaptersinfo

or (direct link)

http://www.rapideuphoria.com/macaddy.zip

If this doesn't solve your problem, then I'll try to provide more help.

-- Brian

new topic     » goto parent     » topic index » view message » categorize

3. Re: structure for GetAdaptersAddresses

Thanks Brian, I had seen your Macaddy and that is almost there but I want to get
the 'Friendly name' - that is the name of the adapter that is shown in the
Network Connections folder and the only way I can see is with the
'GetAdaptersAddresses' which you don't currently have wrapped.

This is for an old program I am rewriting, it is for changing the Ethernet
   address, currently it runs the ipconfig command into a file then reads that for
   the friendly names, I then use these friendly names to build a file as input to a
   netsh command. The running of the ipconfig causes a dos screen to flash up and I
   want to get rid of that, also tieing together the friendly name with the
   'Windows' adapter name may give me another way to change the IP address...

Any help is appreciated...

PeteS

new topic     » goto parent     » topic index » view message » categorize

4. Re: structure for GetAdaptersAddresses

Pete Stoner wrote:
> 
> Thanks Brian, I had seen your Macaddy and that is almost there but I want to
> get the 'Friendly name' - that is the name of the adapter that is shown in the
> Network Connections folder and the only way I can see is with the
> 'GetAdaptersAddresses'
> which you don't currently have wrapped. 
> 
>    This is for an old program I am rewriting, it is for changing the Ethernet
> address, currently it runs the ipconfig command into a file then reads that
> for the friendly names, I then use these friendly names to build a file as
> input
> to a netsh command. The running of the ipconfig causes a dos screen to flash
> up and I want to get rid of that, also tieing together the friendly name with
> the 'Windows' adapter name may give me another way to change the IP address...
> 
> Any help is appreciated...
> 
> PeteS

Do you need more than just the friendly name?  The reason I ask is that
GetAdaptersAddresses is limited to XP/W2K3 and Vista.  I found that
GetInterfaceInfo will return names and is supported on older OSes but I'm not
sure if that's the friendly-name or not.  But it does look easier to wrap.

I'd test it out but I simply don't have the time these days...
-- Brian

new topic     » goto parent     » topic index » view message » categorize

5. Re: structure for GetAdaptersAddresses

Brian Broker wrote:
> 
> Pete Stoner wrote:
> > 
> > Thanks Brian, I had seen your Macaddy and that is almost there but I want to
> > get the 'Friendly name' - that is the name of the adapter that is shown in
> > the
> > Network Connections folder and the only way I can see is with the
> > 'GetAdaptersAddresses'
> > which you don't currently have wrapped. 
> > 
> >    This is for an old program I am rewriting, it is for changing the
> >    Ethernet
> > address, currently it runs the ipconfig command into a file then reads that
> > for the friendly names, I then use these friendly names to build a file as
> > input
> > to a netsh command. The running of the ipconfig causes a dos screen to flash
> > up and I want to get rid of that, also tieing together the friendly name
> > with
> > the 'Windows' adapter name may give me another way to change the IP
> > address...
> > 
> > Any help is appreciated...
> > 
> > PeteS
> 
> Do you need more than just the friendly name?  The reason I ask is that
> GetAdaptersAddresses
> is limited to XP/W2K3 and Vista.  I found that GetInterfaceInfo will return
> names and is supported on older OSes but I'm not sure if that's the
> friendly-name
> or not.  But it does look easier to wrap.
> 
> I'd test it out but I simply don't have the time these days...
> -- Brian

Its unclear if the name from GetInterfaceInfo is the friendly name or not, but
it doesn't seem to be. I need the friendly name so it is clear which adapter the
program is using (and also for the netsh command), but then I need to tie the
friendly name to whatever else I need to display the IP address in use by that
adapter..
PeteS

new topic     » goto parent     » topic index » view message » categorize

6. Re: structure for GetAdaptersAddresses

Brian Broker wrote:
> 
> Pete Stoner wrote:
> > 
> > Thanks Brian, I had seen your Macaddy and that is almost there but I want to
> > get the 'Friendly name' - that is the name of the adapter that is shown in
> > the
> > Network Connections folder and the only way I can see is with the
> > 'GetAdaptersAddresses'
> > which you don't currently have wrapped. 
> > 
> >    This is for an old program I am rewriting, it is for changing the
> >    Ethernet
> > address, currently it runs the ipconfig command into a file then reads that
> > for the friendly names, I then use these friendly names to build a file as
> > input
> > to a netsh command. The running of the ipconfig causes a dos screen to flash
> > up and I want to get rid of that, also tieing together the friendly name
> > with
> > the 'Windows' adapter name may give me another way to change the IP
> > address...
> > 
> > Any help is appreciated...
> > 
> > PeteS
> 
> Do you need more than just the friendly name?  The reason I ask is that
> GetAdaptersAddresses
> is limited to XP/W2K3 and Vista.  I found that GetInterfaceInfo will return
> names and is supported on older OSes but I'm not sure if that's the
> friendly-name
> or not.  But it does look easier to wrap.
> 
> I'd test it out but I simply don't have the time these days...
> -- Brian

I just found this - http://www.gidforums.com/t-6654.html which is a VB
programmer struggling with mapping the same structure. I'm gonna have to do some
detailed reading but it looks like it should give me the answers..
PeteS

new topic     » goto parent     » topic index » view message » categorize

7. Re: structure for GetAdaptersAddresses

Pete:
    Here is Microsoft's example.
    http://support.microsoft.com/kb/175472/EN-US/
Bernie

My files in archive:
w32engin.ew mixedlib.e eu_engin.e win32eru.exw

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

8. Re: structure for GetAdaptersAddresses

Bernie Ryan wrote:
> 
> 
> Pete:
>     Here is Microsoft's example.
>     <a
>     href="http://support.microsoft.com/kb/175472/EN-US/">http://support.microsoft.com/kb/175472/EN-US/</a>
> Bernie
> 
Hi Bernie, Thanks, but that doesn't look like it returns the friendly name, I
need to get the friendly name along with the description (both of which
GetAdaptersAddresses does return).
PeteS

new topic     » goto parent     » topic index » view message » categorize

9. Re: structure for GetAdaptersAddresses

All,
FYI, I got the structure wrapped in the end, and am now getting the list of
adapter info I needed, I'll add it to the archive (after a bit of tidying up!).

Brian, I needed to get the IP address for each adapter, which is returned with
the GetAdaptersInfo call but was missing from your Macaddy wrapper. I've added
that in and sent you a revised file along with an extended demo..

PeteS

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu