private static IEnumerable<Win32MethodsNetwork.SERVER_INFO_101> GetNetServers(string domain, Win32MethodsNetwork.SV_101_TYPES types) { IntPtr pInfo; uint entriesread = 0; uint totalentries = 0; Win32MethodsNetwork.NERR err; unchecked { err = Win32MethodsNetwork.NetServerEnum(null, 101, out pInfo, (uint)-1, ref entriesread, ref totalentries, types, domain, 0); } if ((err == Win32MethodsNetwork.NERR.NERR_SUCCESS || err == Win32MethodsNetwork.NERR.ERROR_MORE_DATA) && pInfo != IntPtr.Zero) { try { int ptr = pInfo.ToInt32(); for (int i = 0; i < entriesread; i++) { yield return (Win32MethodsNetwork.SERVER_INFO_101) Marshal.PtrToStructure(new IntPtr(ptr), typeof(Win32MethodsNetwork.SERVER_INFO_101)); ptr += Marshal.SizeOf(typeof(Win32MethodsNetwork.SERVER_INFO_101)); } } finally { if (pInfo != IntPtr.Zero) { Win32MethodsNetwork.NetApiBufferFree(pInfo); } } } }
internal ShareInfo(Win32MethodsNetwork.SHARE_INFO_1 info) { m_Info = info; }
internal static ServerInfo FromNetApi32(Win32MethodsNetwork.SERVER_INFO_101 info) { var result = new ServerInfo(info.sv101_name); return result; }