By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,894 Members | 1,191 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,894 IT Pros & Developers. It's quick & easy.

GetIfEntry from ip helper

P: n/a
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
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
James,

Try this:

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

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=MAX_IN TERFACE_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 [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2

P: n/a

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OK**************@TK2MSFTNGP12.phx.gbl...
James,

Try this:

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

[MarshalAs(UnmanagedType.ByValTStr,SizeConst=MAX_IN TERFACE_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 [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


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

thanks
James Jenkins
Nov 15 '05 #3

P: n/a
Thanks - Sorry if I sound ignorant - but what are the CONST values shown?


MAX_INTERFACE_NAME_LEN = 256
MAXLEN_PHYSADDR = 8
MAXLEN_IFDESCR = 256

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.