62,046
社区成员
发帖
与我相关
我的任务
分享
[DllImport("MyFunction.dll",EntryPoint="GetPortInfo")]
public static extern UInt32 GetPortInfo(UInt32 Device, Byte Num, IntPtr pPortInfo);
UInt32 GetPortInfo( UInt32 hDevice, unsigned char num, PortInfo& pPortInfo );
[StructLayout(LayoutKind.Sequential,Pack=1)]
public struct port
{
[MarshalAs(UnmanagedType.ByValArray,SizeConst=6)]
public Byte[] mac;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=4)]
public Byte[] ip;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=4)]
public Byte[] mask;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=4)]
public Byte[] gage;
[MarshalAs(UnmanagedType.U4)]
public Uint32 ArpReply;
[MarshalAs(UnmanagedType.U4)]
public Uint32 IcmpReply;
[MarshalAs(UnmangeddType.U1)]
public Byte IgmpEnable;
[MarshalAs(UnmangeddType.U1)]
public Byte MultiPauseEnable;
[MarshalAs(UnmangeddType.U1)]
public Byte DirectPauseEnable;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=6)]
public Byte[] UserDefAddr;
}
struct PortInfo
{
unsigned char mac[6];
unsigned char ip[4];
unsigned char mask[6];
unsigned char gate[6];
ArpReplayEnum ArpReply;
IcmpReplyEnum IcmpReply;
unsigned char IgmpEnable;
unsigned char MultiPauseEnable;
unsigned char DirectPauseEnable;
unsigned char UserDefAddr[6];
}
IntPtr pPortInfo = Marshal.AllocHGlobal(40);
[StructLayout(LayoutKind.Sequential)]
public struct port
{
[MarshalAs(UnmanagedType.ByValArray,SizeConst=6)]
public Byte[] mac;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=4)]
public Byte[] ip;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=4)]
public Byte[] mask;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=4)]
public Byte[] gage;
public UInt16 pad1;
[MarshalAs(UnmanagedType.U4)]
public Uint32 ArpReply;
[MarshalAs(UnmanagedType.U4)]
public Uint32 IcmpReply;
[MarshalAs(UnmangeddType.U1)]
public Byte IgmpEnable;
[MarshalAs(UnmangeddType.U1)]
public Byte MultiPauseEnable;
[MarshalAs(UnmangeddType.U1)]
public Byte DirectPauseEnable;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=6)]
public Byte UserDefAddr;
public UInt16 pad2;
public Byte pad2;
}
IntPtr pPortInfo = Marshal.AllocHGlobal(40);
GetPortInfo( UInt32 hDevice, unsigned char num, PortInfo& pPortInfo );
Marshal.FreeHGlobal(pPortInfo );