日期:2014-05-17 浏览次数:20695 次
[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; [