Querying NT

Question:
Is there a way to query NT 4.0 (programmatically or manually) to have it tell me whether it is NT workstation or NT server? Is the answer in the system registry or in the OS itself?

Answer:
Yes, the following code should work for you. Note that this assumes that anything that isn’t a NT server is a NT workstation, so if that’s not true, you might want some further checks and a return of other than a boolean value.

************************************************

Option Explicit' Constants for type of computerPrivate Enum enumServerType   SV_TYPE_WORKSTATION = &H1&   SV_TYPE_SERVER = &H2&   SV_TYPE_SQLSERVER = &H4&   SV_TYPE_DOMAIN_CTRL = &H8&   SV_TYPE_DOMAIN_BAKCTRL = &H10&   SV_TYPE_NOVELL = &H80&   SV_TYPE_NT = &H1000&   SV_TYPE_WFW = &H2000&   SV_TYPE_SERVER_NT = &H8000&   SV_TYPE_WINDOWS = &H400000   SV_TYPE_ALL = &HFFFFEnd Enum' Type used by NetServerGetInfo and NetServerSetInfoPrivate Type SERVER_INFO_101    sv101_platform_id As Long    sv101_name As Long    sv101_ver_major As Long    sv101_ver_minor As Long    sv101_type As Long    sv101_comment As LongEnd Type      ' API declarationsPrivate Declare Function NetServerGetInfo _   Lib "Netapi32" _      (sServerName As Byte, _       ByVal lLevel As Long, _       vBuffer As Long) As LongPrivate Declare Function NetApiBufferFree _   Lib "netapi32.dll" _   (ByVal lngPtrBuffer As Long) As LongPrivate Declare Function lstrlenW _   Lib "kernel32" _   (ByVal lpString As Long) As LongPublic Declare Sub CopyMem _   Lib "kernel32" Alias "RtlMoveMemory" _   (dest As Any, vSrc As Any, ByVal lSize As Long)Public Sub Main()   Debug.Print IsServer("")   Debug.Print IsServer("PDCNew")End SubPublic Function IsServer(Optional ByVal xi_strServerName As String = "") As Boolean   Dim p_bytServerName()         As Byte   Dim p_lngRtn                  As Long   Dim p_lngSrvInfoRtn           As Long   Dim p_typServerInfo101        As SERVER_INFO_101   Dim p_lngServEnumLevel        As Long      ' Initialize the variables   If Trim$(xi_strServerName) = vbNullString Then      p_bytServerName = vbNullChar   Else      p_bytServerName = Trim$(xi_strServerName) & vbNullChar   End If   p_lngServEnumLevel = 101     ' Call NetServerEnum to get a list of Servers   If Trim$(xi_strServerName) = vbNullString Then      p_lngRtn = NetServerGetInfo(sServerName:=ByVal p_bytServerName(0), _                                  lLevel:=p_lngServEnumLevel, _                                  vBuffer:=p_lngSrvInfoRtn)   Else      p_lngRtn = NetServerGetInfo(sServerName:=p_bytServerName(0), _                                  lLevel:=p_lngServEnumLevel, _                                  vBuffer:=p_lngSrvInfoRtn)   End If      If p_lngRtn = 0 Then      ' xxx      CopyMem p_typServerInfo101, _              ByVal p_lngSrvInfoRtn, _              Len(p_typServerInfo101)      If p_typServerInfo101.sv101_type And enumServerType.SV_TYPE_SERVER_NT Then         IsServer = True      ElseIf p_typServerInfo101.sv101_type And enumServerType.SV_TYPE_DOMAIN_BAKCTRL Then         IsServer = True      ElseIf p_typServerInfo101.sv101_type And enumServerType.SV_TYPE_DOMAIN_CTRL Then         IsServer = True      Else         IsServer = False      End If         Else      Debug.Print "Error: " & Err.LastDllError   End If   End Function

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS