using System; using System.Runtime.InteropServices; using System.Security; namespace MediaBrowser.Common.Implementations.NetworkManagement { /// /// Class NativeMethods /// [SuppressUnmanagedCodeSecurity] public static class NativeMethods { //declare the Netapi32 : NetServerEnum method import /// /// Nets the server enum. /// /// Name of the server. /// The dw level. /// The p buf. /// The dw pref max len. /// The dw entries read. /// The dw total entries. /// Type of the dw server. /// The domain. /// The dw resume handle. /// System.Int32. [DllImport("Netapi32", CharSet = CharSet.Auto, SetLastError = true), SuppressUnmanagedCodeSecurity] public static extern int NetServerEnum( string ServerName, // must be null int dwLevel, ref IntPtr pBuf, int dwPrefMaxLen, out int dwEntriesRead, out int dwTotalEntries, int dwServerType, string domain, // null for login domain out int dwResumeHandle ); //declare the Netapi32 : NetApiBufferFree method import /// /// Nets the API buffer free. /// /// The p buf. /// System.Int32. [DllImport("Netapi32", SetLastError = true), SuppressUnmanagedCodeSecurity] public static extern int NetApiBufferFree( IntPtr pBuf); } //create a _SERVER_INFO_100 STRUCTURE /// /// Struct _SERVER_INFO_100 /// [StructLayout(LayoutKind.Sequential)] public struct _SERVER_INFO_100 { /// /// The sv100_platform_id /// internal int sv100_platform_id; /// /// The sv100_name /// [MarshalAs(UnmanagedType.LPWStr)] internal string sv100_name; } }