/// <summary> /// Moves to the next server/machine/domain /// </summary> /// <returns> </returns> public bool MoveNext() { bool result = false; if (++this.currentItem < this.itemCount) { int newOffset = this.serverInfoPtr.ToInt32() + SERVER_INFO_101_SIZE * this.currentItem; Win32API.SERVER_INFO_101 si = (Win32API.SERVER_INFO_101) Marshal.PtrToStructure(new IntPtr(newOffset), typeof(Win32API.SERVER_INFO_101)); this.currentServerName = Marshal.PtrToStringAuto(si.lpszServerName); result = true; } return(result); }
/// <summary> /// Returns the server type of the named server. /// </summary> /// <param name="serverName"> </param> /// <returns> </returns> public static ServerType GetServerType(string serverName) { ServerType result = ServerType.None; IntPtr serverInfoPtr = IntPtr.Zero; uint rc = Win32API.NetServerGetInfo(serverName, 101, ref serverInfoPtr); if (rc != 0 && serverInfoPtr != IntPtr.Zero) { Win32API.SERVER_INFO_101 si = (Win32API.SERVER_INFO_101)Marshal.PtrToStructure(serverInfoPtr, typeof(Win32API.SERVER_INFO_101)); result = (ServerType)si.dwType; Win32API.NetApiBufferFree(serverInfoPtr); serverInfoPtr = IntPtr.Zero; } return(result); }