Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Detecting NT Workstation vs. Server

Posted on 1999-01-04
5
Medium Priority
?
333 Views
Last Modified: 2013-12-03
I have what should be a simple question, but I can't find it documented anywhere.  What is the CORRECT <official> way to check for NT Workstation or NT Server.  GetVersionEx() is great for figuring out Service Pack levels / Version number, but contains no information about if it is NT Workstation or Server, How does Microsoft recomend doing this?
0
Comment
Question by:jonstelly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 800 total points
ID: 1418040
See the Microsoft Developer's Network Knowledge Base article Q124305. The registry entry '\hkey_local_machine\system\currentcontrolset\control\productoptions\producttype' contains one of these entries:
ProductType->System
Winnt Workstation
Servernt Server
Lanmannt Advanced Server
 

0
 
LVL 86

Expert Comment

by:jkr
ID: 1418041
Ooops, the last lines should have been a 'table', let me see whether i can improve the formatting ;-)
ProductType->System
'Winnt' means Workstation
'Servernt' means Server
'Lanmannt' means Advanced Server
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 1418042
And one other thing i forgot to mention - i didn't care of uppercase or lowercase, as MS uses the above terms uppercase, but i've often seen them in lowecase, also. So i suggest a 'case insensitive' comparation ;-)
0
 
LVL 86

Expert Comment

by:jkr
ID: 1418043
Hmm, i took this as a chance to take a view at this article again, and as it is not that large, i decided to post it ;-)
Though it was intended for NT3.x, it still applies for NT4.0...

Knowledge Base
Which Windows NT (Server or Workstation) Is Running?
Article ID: Q124305
Creation Date: 27-DEC-1994
Revision Date: 26-JAN-1996
The information in this article applies to:

Microsoft Win32 Application Programming Interface (API) included with:

    - Microsoft Windows NT versions 3.1 and 3.5


SUMMARY


You can determine which variant of Windows NT (Windows NT Server or Windows NT Workstation) is running by using the technique described in this article. Then you can use this information to execute code based on which variant is running.


MORE INFORMATION


To find out which product is currently running, you need to determine the value of the following registry entry:

HKEY_LOCAL_MACHINE\SYSTEM\ CurrentControlSet Control\ ProductOptions

Use the following table to determine which product is running:


ProductType   Product
WINNT         Windows NT Workstation is running
SERVERNT      Windows NT Server is running
LANMANNT      Windows NT Advanced Server is running (Server as Domain
              controller)

The sample code creates a WhichNTProduct() function to indicate whether Windows NT Server or Windows NT Workstation in currently running. The following table gives the meaning for each return value:

Return Value       Meaning
RTN_SERVER         Windows NT Server is running
RTN_WORKSTATION    Windows NT Workstation is running
RTN_NTAS           Windows NT Advanced Server is running
RTN_UNKNOWN        Unknown product type was encountered
RTN_ERROR          Error occurred

To get extended error information, call GetLastError(). Some error checking is omitted, for brevity.

Sample Code


#define RTN_UNKNOWN 0 #define RTN_SERVER 1 #define RTN_WORKSTATION 2 #define RTN_NTAS 3 #define RTN_ERROR 13

unsigned int WhichNTProduct(void)

DWORD WhichNTProduct(

    void
    )
{
    #define MY_BUFSIZE 32 // arbitrary. Use dynamic allocation
    HKEY hKey;
    TCHAR szProductType[MY_BUFSIZE];
    DWORD dwBufLen=MY_BUFSIZE;
    LONG lRet;

    if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,

TEXT("SYSTEM\\CurrentControlSet\\Control\\ProductOptions"),
                    0,
                    KEY_QUERY_VALUE,
                    &hKey) != ERROR_SUCCESS) return RTN_ERROR;

    lRet = RegQueryValueEx(hKey,
                    TEXT("ProductType"),
                    NULL,
                    NULL,
                    (LPBYTE)szProductType,
                    &dwBufLen);

    RegCloseKey(hKey);

    if(lRet != ERROR_SUCCESS) return RTN_ERROR;

    // check product options, in order of likelihood
    if(lstrcmpi(TEXT("WINNT"), szProductType) == 0) return RTN_WORKSTATION;
    if(lstrcmpi(TEXT("SERVERNT"), szProductType) == 0) return RTN_SERVER;
    if(lstrcmpi(TEXT("LANMANNT"), szProductType) == 0) return RTN_NTAS;

    // else return Unknown
    return RTN_UNKNOWN;
}

0
 

Author Comment

by:jonstelly
ID: 1418044
Thanks for the answer, that was exactly what I was looking for.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question