Exemplo n.º 1
0
        /// <summary>
        /// Moves to the next server/machine/domain
        /// </summary>
        /// <returns></returns>
        public bool MoveNext()
        {
            bool result = false;

            if (++currentItem < itemCount)
            {
                int newOffset = serverInfoPtr.ToInt32() + SERVER_INFO_101_SIZE * currentItem;
                Win32API.SERVER_INFO_101 si = (Win32API.SERVER_INFO_101)Marshal.PtrToStructure(new IntPtr(newOffset), typeof(Win32API.SERVER_INFO_101));
                currentServerName = Marshal.PtrToStringAuto(si.lpszServerName);
                result            = true;
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <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)
            {
                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);
        }