From 51b3c32e2cc84778212531d72665d2c5f567f34a Mon Sep 17 00:00:00 2001 From: LukePulverenti Date: Tue, 26 Feb 2013 16:05:52 -0500 Subject: a little more consolidation --- .../NetworkManagement/NativeMethods.cs | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 MediaBrowser.Common.Implementations/NetworkManagement/NativeMethods.cs (limited to 'MediaBrowser.Common.Implementations/NetworkManagement/NativeMethods.cs') diff --git a/MediaBrowser.Common.Implementations/NetworkManagement/NativeMethods.cs b/MediaBrowser.Common.Implementations/NetworkManagement/NativeMethods.cs new file mode 100644 index 000000000..7c8a09493 --- /dev/null +++ b/MediaBrowser.Common.Implementations/NetworkManagement/NativeMethods.cs @@ -0,0 +1,72 @@ +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; + } +} -- cgit v1.2.3