GetIfEntry from ip helper

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hi - I need to implement the GetIfEntry function from the Ip Helper API and
am having some real problems converting the MIB_IFROW structure to C# - In
particluar I cannot fiqure out how to declare it properly. I realise that it
requires some additional parameters on some of its members attributes (like
Charset=Unicode etc). So can anyone please fill me in on the declaration
side of the MIB_IFROW structure please - layout and other attributes -
thanks

JJ
 
James,

Try this:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
struct MIB_IFROW
{

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=MAX_INTERFACE_NAME_LEN)]
public string wszName;
public uint dwIndex, dwType, dwMtu, dwSpeed, dwPhysAddrLen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=MAXLEN_PHYSADDR)]
public byte[] bPhysAddr;
public uint dwAdminStatus, dwOperStatus, dwLastChange;
public uint dwInOctets, dwInUcastPkts, dwInNUcastPkts;
public uint dwInDiscards, dwInErrors, dwInUnknownProtos;
public uint dwOutOctets, dwOutUcastPkts, dwOutNUcastPkts;
public uint dwOutDiscards, dwOutErrors, dwOutQLen, dwDescrLen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=MAXLEN_IFDESCR)]
public byte[] bDescr;
}



Mattias
 
Mattias Sjögren said:
James,

Try this:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
struct MIB_IFROW
{

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=MAX_INTERFACE_NAME_LEN)]
public string wszName;
public uint dwIndex, dwType, dwMtu, dwSpeed, dwPhysAddrLen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=MAXLEN_PHYSADDR)]
public byte[] bPhysAddr;
public uint dwAdminStatus, dwOperStatus, dwLastChange;
public uint dwInOctets, dwInUcastPkts, dwInNUcastPkts;
public uint dwInDiscards, dwInErrors, dwInUnknownProtos;
public uint dwOutOctets, dwOutUcastPkts, dwOutNUcastPkts;
public uint dwOutDiscards, dwOutErrors, dwOutQLen, dwDescrLen;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=MAXLEN_IFDESCR)]
public byte[] bDescr;
}



Mattias

Thanks - Sorry if I sound ignorant - but what are the CONST values shown?

thanks
James Jenkins
 
Back
Top