[StructLayout(LayoutKind.Sequential)] public struct NAME_BUFFER { [MarshalAs(UnmanagedType.ByValArray, SizeConst=(int)NCBCONST.NCBNAMSZ)] public byte[] name; public byte name_num; public byte name_flags; }
[StructLayout(LayoutKind.Sequential)] public struct NCB { public byte ncb_command; public byte ncb_retcode; public byte ncb_lsn; public byte ncb_num; public IntPtr ncb_buffer; public ushort ncb_length; [MarshalAs(UnmanagedType.ByValArray, SizeConst=(int)NCBCONST.NCBNAMSZ)] public byte[] ncb_callname; [MarshalAs(UnmanagedType.ByValArray, SizeConst=(int)NCBCONST.NCBNAMSZ)] public byte[] ncb_name; public byte ncb_rto; public byte ncb_sto; public IntPtr ncb_post; public byte ncb_lana_num; public byte ncb_cmd_cplt; [MarshalAs(UnmanagedType.ByValArray, SizeConst=10)] public byte[] ncb_reserve; public IntPtr ncb_event; }
[StructLayout(LayoutKind.Sequential)] public struct LANA_ENUM { public byte length; [MarshalAs(UnmanagedType.ByValArray, SizeConst=(int)NCBCONST.MAX_LANA)] public byte[] lana; }
[StructLayout(LayoutKind.Auto)] public struct ASTAT { public ADAPTER_STATUS adapt; [MarshalAs(UnmanagedType.ByValArray, SizeConst=(int)NCBCONST.NUM_NAMEBUF)] public NAME_BUFFER[] NameBuff; } public class Win32API { [DllImport("NETAPI32.DLL")] public static extern char Netbios(ref NCB ncb); }
public string GetMacAddress() { string addr=""; try { int cb; ASTAT adapter;