How i detect if the OS is a WINNT Server or WINNT Workstation

0 views
Skip to first unread message

Marcio

unread,
Apr 30, 2002, 10:54:19 AM4/30/02
to
Hi,

Does anyone know how i detect if the OS is a Windows NT Server or Windows NT
Workstation?

Thanks

Marcio


Marian Wendt

unread,
Apr 30, 2002, 11:20:36 AM4/30/02
to
Take a look at JclSysInfo in the JCL from http://www.delphi-jedi.org/


Dave Nottage (TeamB)

unread,
Apr 30, 2002, 11:35:24 AM4/30/02
to
"Marcio" wrote:
> Does anyone know how i detect if the OS is a Windows NT Server or Windows
NT
> Workstation?

http://groups.google.com/groups?hl=en&threadm=3c75fcf3_2%40dnews&rnum=1&prev
=/groups%3Fhl%3Den%26selm%3D3c75fcf3_2%2540dnews

--
Dave Nottage (TeamB)


Vitaliy Jungle

unread,
Apr 30, 2002, 7:02:47 PM4/30/02
to
You must read in system register the following key:
HKLM\System\CurrentControlSet\Control\ProductOptions

The value of "WINNT" is for Windows NT Workstation
The value of "SERVERNT" is for Windows NT Server (3.5 and higher )
The value of "LANMAN" is for Windows NT Advanced Server ver 3.1

Best regards, Vitaliy Jungle
xxm...@grsu.grodno.by
Grodno State University, Physical and Technical Department


"Marcio" <mav...@ig.com.br> сообщил/сообщила в новостях следующее:
news:3cceafee_1@dnews...

Will DeWitt

unread,
Apr 30, 2002, 11:45:32 PM4/30/02
to
"Marcio" <mav...@ig.com.br> wrote in message news:3cceafee_1@dnews...

> Hi,
>
> Does anyone know how i detect if the OS is a Windows NT Server or Windows
NT
> Workstation?

As long as you require Windows NT 4.0 SP6+, this'll work on NT4/2000/XP
(though not on '9x, but then you didn't mention if you needed compatibility
with '9x or not). Use GetVersionEx, but instead of specifying an
OSVERSIONINFO record, use the OSVERSIONINFOEX record. This record has a few
additional fields that will be of use, specifically wSuiteMask and
wProductType. If you need compatibility with '9x, you should probably use
the regular OSVERSIONINFO record first, then verify that dwPlatformId is set
to VER_PLATFORM_WIN32_NT. So your code would look something like this--

var
OldVer: OSVERSIONINFO;
NewVer: OSVERSIONINFOEX;
begin
FillChar(OldVer, SizeOf(OldVer), 0);
OldVer.dwOSVersionInfoSize := SizeOf(OldVer);
if (GetVersionEx(OldVer)) then begin
if (OldVer.dwPlatformId = VER_PLATFORM_WIN32_NT) then begin
FillChar(NewVer, SizeOf(NewVer), 0);
NewVer.dwOSVersionInfoSize := SizeOf(NewVer);
if (GetVersionEx(NewVer)) then begin
if (NewVer.wProductType = VER_NT_WORKSTATION) then begin
// Code you want to run if it's NT Workstation/2000
Professional, etc
else begin
// Probably safe to assume it's a server, or you could
inspect wSuiteMask for more details!
end;
end;
end;
end;
end;

The above is totally untested, but hopefully it'll work and be helpful.
Good luck. =)

Will

Marcio

unread,
May 3, 2002, 8:10:12 AM5/3/02
to
Thanks all.
"Marcio" <mav...@ig.com.br> escreveu na mensagem news:3cceafee_1@dnews...
Reply all
Reply to author
Forward
0 new messages