How can I get if the Windows running is a server version?

T

ThunderMusic

Hi,
How can I get if the Windows running is a server version?

Is there a property somewhere that can tell me if the Windows version is a
server edition (including server, advanced server, web server, etc) or just
a workstation (if it's not a workstation, then it's a server). My app must
verifies that for security reasons. It should work from at least windows
2000 (Windows 98 and ME, would appreciated to, but if it's not possible,
I'll put it in the system requirements)

Thanks

ThunderMusic
 
T

ThunderMusic

Just to be sure, what I mean by "from at least Windows 2000", I mean "from
Windows 2000 and up (so XP and 2003, et al.)
 
J

Jay B. Harlow [MVP - Outlook]

ThunderMusic,
Have you looked at System.Environment.OSVersion?

For details see:
http://support.microsoft.com/kb/304289


--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


"ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| Hi,
| How can I get if the Windows running is a server version?
|
| Is there a property somewhere that can tell me if the Windows version is a
| server edition (including server, advanced server, web server, etc) or
just
| a workstation (if it's not a workstation, then it's a server). My app must
| verifies that for security reasons. It should work from at least windows
| 2000 (Windows 98 and ME, would appreciated to, but if it's not possible,
| I'll put it in the system requirements)
|
| Thanks
|
| ThunderMusic
|
|
 
T

ThunderMusic

Thanks, but it gives me the version of windows running, 95, 98, 2000, xp,
2003, etc, but it doesn't tell me if the Windows edition is server or
workstation, even the build numbers are the same for both(if I'm not
mistaken). Whether it is win9x, 2000, xp or 2003 doesn't matter to me, I
just want to know if it's workstation(or home, or pro) or server.

Is there another way to know? (by a method, a property or even a registry
key)

Thanks
 
J

Jay B. Harlow [MVP - Outlook]

ThunderMusic,
The only other options I can think of is GetSystemMetrics, however after a
quick look I don't see a SM_SERVER value (just a SM_SERVERR2 for Windows
Server 2003 "R2" value).

I know MSDN Magazine (http://msdn.microsoft.com/msdnmag) has a topic every
once in a while on getting the "real" OS you are on, however I don't see one
right now.


Here is some info on use GetSystemMetrics from an earlier post of mine:

According to the Microsoft Tablet PC SDK:

<quote>
Q. How can I determine if my application is running on a Tablet PC?
A. Use the Windows GetSystemMetrics API and pass in SM_TABLETPC as the value
of the index. SM_TABLETPC is defined in Winuser.h. The value of SM_TABLETPC
is 86. The method returns True or nonzero if the Microsoft Windows XP Tablet
PC Edition operating system is running; False or zero otherwise.

Applications should not rely on a true or nonzero value to mean all Tablet
PC components are installed and working. See the following question for
details on how to determine if Tablet PC components are installed.

</quote>

There is also a MediaCenter system metrics value.

I would expect System.Windows.Forms.SystemInformation would list both values
as it gives most other SystemMetrics, however it appears to be missing
TabletPC (SM_TABLETPC) & MediaCenter (SM_MEDIACENTER).

You can use code similar to:

Public Enum SystemMetric As Integer
TabletPC = 86
MediaCenter = 87
End Enum

Declare Auto Function GetSystemMetrics Lib "User32" (ByVal index As
SystemMetric) As Integer

If GetSystemMetrics(SystemMetric.TabletPC) <> 0 Then
Debug.WriteLine("On a Tablet PC")
Else
Debug.WriteLine("Not on a Tablet PC")
End If

If GetSystemMetrics(SystemMetric.MediaCenter ) <> 0 Then
Debug.WriteLine("On a Media Center PC")
Else
Debug.WriteLine("Not on a Media Center PC")
End If

I've used the Tablet PC value reliably, I don't have a Media Center PC to
verify the Media Center value.

I'm not sure how to tell the difference between Home & Pro.

Hope this helps
Jay


--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


"ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| Thanks, but it gives me the version of windows running, 95, 98, 2000, xp,
| 2003, etc, but it doesn't tell me if the Windows edition is server or
| workstation, even the build numbers are the same for both(if I'm not
| mistaken). Whether it is win9x, 2000, xp or 2003 doesn't matter to me, I
| just want to know if it's workstation(or home, or pro) or server.
|
| Is there another way to know? (by a method, a property or even a registry
| key)
|
| Thanks
|
| "Jay B. Harlow [MVP - Outlook]" <[email protected]> a écrit
dans
| le message de [email protected]...
| > ThunderMusic,
| > Have you looked at System.Environment.OSVersion?
| >
| > For details see:
| > http://support.microsoft.com/kb/304289
| >
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > "ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| > | > | Hi,
| > | How can I get if the Windows running is a server version?
| > |
| > | Is there a property somewhere that can tell me if the Windows version
is
| > a
| > | server edition (including server, advanced server, web server, etc) or
| > just
| > | a workstation (if it's not a workstation, then it's a server). My app
| > must
| > | verifies that for security reasons. It should work from at least
windows
| > | 2000 (Windows 98 and ME, would appreciated to, but if it's not
possible,
| > | I'll put it in the system requirements)
| > |
| > | Thanks
| > |
| > | ThunderMusic
| > |
| > |
| >
| >
|
|
 
T

ThunderMusic

ok, you lead me on a good path, but the information is not in
GetSystemMetrics. Instead, I found it in the GetVersionEx function I got
from the System Information Functions link at the bottom of the page.

So for those who want to know, the information is in GetVersionEx using a
pointer of type OSVERSIONINFOEX, you can get the information into the
wProductType property. It can be one of the following values :
VER_NT_WORKSTATION, VER_NT_DOMAIN_CONTROLLER or VER_NT_SERVER.

Now, all I have to do is find a way to access this function from within my
..net app (I never worked with win32 APIs from within .NET before. Anybody
have a link to get me on the right track? (I know there are many many many
examples on the web, I will probably find one suitable before anyone post
here, but if I don't.....))

Thanks a lot

ThunderMusic

Jay B. Harlow said:
ThunderMusic,
The only other options I can think of is GetSystemMetrics, however after a
quick look I don't see a SM_SERVER value (just a SM_SERVERR2 for Windows
Server 2003 "R2" value).

I know MSDN Magazine (http://msdn.microsoft.com/msdnmag) has a topic every
once in a while on getting the "real" OS you are on, however I don't see
one
right now.


Here is some info on use GetSystemMetrics from an earlier post of mine:

According to the Microsoft Tablet PC SDK:

<quote>
Q. How can I determine if my application is running on a Tablet PC?
A. Use the Windows GetSystemMetrics API and pass in SM_TABLETPC as the
value
of the index. SM_TABLETPC is defined in Winuser.h. The value of
SM_TABLETPC
is 86. The method returns True or nonzero if the Microsoft Windows XP
Tablet
PC Edition operating system is running; False or zero otherwise.

Applications should not rely on a true or nonzero value to mean all Tablet
PC components are installed and working. See the following question for
details on how to determine if Tablet PC components are installed.

</quote>

There is also a MediaCenter system metrics value.

I would expect System.Windows.Forms.SystemInformation would list both
values
as it gives most other SystemMetrics, however it appears to be missing
TabletPC (SM_TABLETPC) & MediaCenter (SM_MEDIACENTER).

You can use code similar to:

Public Enum SystemMetric As Integer
TabletPC = 86
MediaCenter = 87
End Enum

Declare Auto Function GetSystemMetrics Lib "User32" (ByVal index As
SystemMetric) As Integer

If GetSystemMetrics(SystemMetric.TabletPC) <> 0 Then
Debug.WriteLine("On a Tablet PC")
Else
Debug.WriteLine("Not on a Tablet PC")
End If

If GetSystemMetrics(SystemMetric.MediaCenter ) <> 0 Then
Debug.WriteLine("On a Media Center PC")
Else
Debug.WriteLine("Not on a Media Center PC")
End If

I've used the Tablet PC value reliably, I don't have a Media Center PC to
verify the Media Center value.

I'm not sure how to tell the difference between Home & Pro.

Hope this helps
Jay


--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


"ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| Thanks, but it gives me the version of windows running, 95, 98, 2000,
xp,
| 2003, etc, but it doesn't tell me if the Windows edition is server or
| workstation, even the build numbers are the same for both(if I'm not
| mistaken). Whether it is win9x, 2000, xp or 2003 doesn't matter to me, I
| just want to know if it's workstation(or home, or pro) or server.
|
| Is there another way to know? (by a method, a property or even a
registry
| key)
|
| Thanks
|
| "Jay B. Harlow [MVP - Outlook]" <[email protected]> a écrit
dans
| le message de [email protected]...
| > ThunderMusic,
| > Have you looked at System.Environment.OSVersion?
| >
| > For details see:
| > http://support.microsoft.com/kb/304289
| >
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > "ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| > | > | Hi,
| > | How can I get if the Windows running is a server version?
| > |
| > | Is there a property somewhere that can tell me if the Windows
version
is
| > a
| > | server edition (including server, advanced server, web server, etc)
or
| > just
| > | a workstation (if it's not a workstation, then it's a server). My
app
| > must
| > | verifies that for security reasons. It should work from at least
windows
| > | 2000 (Windows 98 and ME, would appreciated to, but if it's not
possible,
| > | I'll put it in the system requirements)
| > |
| > | Thanks
| > |
| > | ThunderMusic
| > |
| > |
| >
| >
|
|
 
D

Dragon

Hi,
Now, all I have to do is find a way to access this function from within my
.net app (I never worked with win32 APIs from within .NET before. Anybody
have a link to get me on the right track? (I know there are many many many
examples on the web, I will probably find one suitable before anyone post
here, but if I don't.....))

In case you didn't...

~
Friend Declare Auto Function GetVersionEx Lib "kernel32.dll" ( _
ByRef lpVersionInfo As OSVersionInfoEx _
) As Boolean

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> Friend
Structure OSVersionInfoEx
Public dwOSVersionInfoSize As Integer
Public dwMajorVersion As Integer
Public dwMinorVersion As Integer
Public dwBuildNumber As Integer
Public dwPlatformId As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> Public
szCSDVersion As String
Public wServicePackMajor As Short
Public wServicePackMinor As Short
Public wSuiteMask As Short
Public wProductType As Byte
Public wReserved As Byte
End Structure

Const VER_NT_DOMAIN_CONTROLLER As Byte = 2
Const VER_NT_SERVER As Byte = 3
Const VER_NT_WORKSTATION As Byte = 1

Protected Overrides Sub OnClick(ByVal e As System.EventArgs)
MyBase.OnClick(e)
Dim OSVIEx As OSVersionInfoEx
OSVIEx.dwOSVersionInfoSize =
Marshal.SizeOf(GetType(OSVersionInfoEx))
GetVersionEx(OSVIEx)
Select Case OSVIEx.wProductType
Case VER_NT_DOMAIN_CONTROLLER
MessageBox.Show("That's a DOMAIN CONTROLLER!")
Case VER_NT_SERVER
MessageBox.Show("It's server OS")
Case VER_NT_WORKSTATION
MessageBox.Show("Workstation. Just a workstation.")
Case 0
MessageBox.Show("Ha! It's probably a 98/ME system, or an
old version of NT.")
Case Else
MessageBox.Show("??? Your kernel32.dll is broken?")
End Select
End Sub
~

HTH,
Roman
 
J

Jay B. Harlow [MVP - Outlook]

ThunderMusic,
Doh! I looked at GetVersionEx & OSVERSIONINFO only, I didn't check
OSVERSIONINFOEX.

Thanks for letting us know you found it, I'll have to save a copy of this
for next time.

Let us know if you can't get Dragon's code to work (it looks like it should
work for you).

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect & Enthusiast
T.S. Bradley - http://www.tsbradley.net


"ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| ok, you lead me on a good path, but the information is not in
| GetSystemMetrics. Instead, I found it in the GetVersionEx function I got
| from the System Information Functions link at the bottom of the page.
|
| So for those who want to know, the information is in GetVersionEx using a
| pointer of type OSVERSIONINFOEX, you can get the information into the
| wProductType property. It can be one of the following values :
| VER_NT_WORKSTATION, VER_NT_DOMAIN_CONTROLLER or VER_NT_SERVER.
|
| Now, all I have to do is find a way to access this function from within my
| .net app (I never worked with win32 APIs from within .NET before. Anybody
| have a link to get me on the right track? (I know there are many many many
| examples on the web, I will probably find one suitable before anyone post
| here, but if I don't.....))
|
| Thanks a lot
|
| ThunderMusic
|
| "Jay B. Harlow [MVP - Outlook]" <[email protected]> a écrit
dans
| le message de news: (e-mail address removed)...
| > ThunderMusic,
| > The only other options I can think of is GetSystemMetrics, however after
a
| > quick look I don't see a SM_SERVER value (just a SM_SERVERR2 for Windows
| > Server 2003 "R2" value).
| >
<<snip>>
 
P

Phil Wilson

http://pinvoke.net/default.aspx/kernel32.GetVersionEx
--
Phil Wilson [MVP Windows Installer]
----
ThunderMusic said:
ok, you lead me on a good path, but the information is not in
GetSystemMetrics. Instead, I found it in the GetVersionEx function I got
from the System Information Functions link at the bottom of the page.

So for those who want to know, the information is in GetVersionEx using a
pointer of type OSVERSIONINFOEX, you can get the information into the
wProductType property. It can be one of the following values :
VER_NT_WORKSTATION, VER_NT_DOMAIN_CONTROLLER or VER_NT_SERVER.

Now, all I have to do is find a way to access this function from within my
.net app (I never worked with win32 APIs from within .NET before. Anybody
have a link to get me on the right track? (I know there are many many many
examples on the web, I will probably find one suitable before anyone post
here, but if I don't.....))

Thanks a lot

ThunderMusic

Jay B. Harlow said:
ThunderMusic,
The only other options I can think of is GetSystemMetrics, however after
a
quick look I don't see a SM_SERVER value (just a SM_SERVERR2 for Windows
Server 2003 "R2" value).

I know MSDN Magazine (http://msdn.microsoft.com/msdnmag) has a topic
every
once in a while on getting the "real" OS you are on, however I don't see
one
right now.


Here is some info on use GetSystemMetrics from an earlier post of mine:

According to the Microsoft Tablet PC SDK:

<quote>
Q. How can I determine if my application is running on a Tablet PC?
A. Use the Windows GetSystemMetrics API and pass in SM_TABLETPC as the
value
of the index. SM_TABLETPC is defined in Winuser.h. The value of
SM_TABLETPC
is 86. The method returns True or nonzero if the Microsoft Windows XP
Tablet
PC Edition operating system is running; False or zero otherwise.

Applications should not rely on a true or nonzero value to mean all
Tablet
PC components are installed and working. See the following question for
details on how to determine if Tablet PC components are installed.

</quote>

There is also a MediaCenter system metrics value.

I would expect System.Windows.Forms.SystemInformation would list both
values
as it gives most other SystemMetrics, however it appears to be missing
TabletPC (SM_TABLETPC) & MediaCenter (SM_MEDIACENTER).

You can use code similar to:

Public Enum SystemMetric As Integer
TabletPC = 86
MediaCenter = 87
End Enum

Declare Auto Function GetSystemMetrics Lib "User32" (ByVal index As
SystemMetric) As Integer

If GetSystemMetrics(SystemMetric.TabletPC) <> 0 Then
Debug.WriteLine("On a Tablet PC")
Else
Debug.WriteLine("Not on a Tablet PC")
End If

If GetSystemMetrics(SystemMetric.MediaCenter ) <> 0 Then
Debug.WriteLine("On a Media Center PC")
Else
Debug.WriteLine("Not on a Media Center PC")
End If

I've used the Tablet PC value reliably, I don't have a Media Center PC to
verify the Media Center value.

I'm not sure how to tell the difference between Home & Pro.

Hope this helps
Jay


--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


"ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| Thanks, but it gives me the version of windows running, 95, 98, 2000,
xp,
| 2003, etc, but it doesn't tell me if the Windows edition is server or
| workstation, even the build numbers are the same for both(if I'm not
| mistaken). Whether it is win9x, 2000, xp or 2003 doesn't matter to me,
I
| just want to know if it's workstation(or home, or pro) or server.
|
| Is there another way to know? (by a method, a property or even a
registry
| key)
|
| Thanks
|
| "Jay B. Harlow [MVP - Outlook]" <[email protected]> a écrit
dans
| le message de [email protected]...
| > ThunderMusic,
| > Have you looked at System.Environment.OSVersion?
| >
| > For details see:
| > http://support.microsoft.com/kb/304289
| >
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > "ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| > | > | Hi,
| > | How can I get if the Windows running is a server version?
| > |
| > | Is there a property somewhere that can tell me if the Windows
version
is
| > a
| > | server edition (including server, advanced server, web server, etc)
or
| > just
| > | a workstation (if it's not a workstation, then it's a server). My
app
| > must
| > | verifies that for security reasons. It should work from at least
windows
| > | 2000 (Windows 98 and ME, would appreciated to, but if it's not
possible,
| > | I'll put it in the system requirements)
| > |
| > | Thanks
| > |
| > | ThunderMusic
| > |
| > |
| >
| >
|
|
 
M

m.posseth

Well actually this topic has been covered by dr GUI ( MSDN ) somewhere in
2002 :)

here is the article

http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraskdr/html/askgui06042002.asp

it will even show the sort of server the proggy is running on small busines
server etc etc

regards

Michel Posseth [MCP]




ThunderMusic said:
ok, you lead me on a good path, but the information is not in
GetSystemMetrics. Instead, I found it in the GetVersionEx function I got
from the System Information Functions link at the bottom of the page.

So for those who want to know, the information is in GetVersionEx using a
pointer of type OSVERSIONINFOEX, you can get the information into the
wProductType property. It can be one of the following values :
VER_NT_WORKSTATION, VER_NT_DOMAIN_CONTROLLER or VER_NT_SERVER.

Now, all I have to do is find a way to access this function from within my
.net app (I never worked with win32 APIs from within .NET before. Anybody
have a link to get me on the right track? (I know there are many many many
examples on the web, I will probably find one suitable before anyone post
here, but if I don't.....))

Thanks a lot

ThunderMusic

Jay B. Harlow said:
ThunderMusic,
The only other options I can think of is GetSystemMetrics, however after
a
quick look I don't see a SM_SERVER value (just a SM_SERVERR2 for Windows
Server 2003 "R2" value).

I know MSDN Magazine (http://msdn.microsoft.com/msdnmag) has a topic
every
once in a while on getting the "real" OS you are on, however I don't see
one
right now.


Here is some info on use GetSystemMetrics from an earlier post of mine:

According to the Microsoft Tablet PC SDK:

<quote>
Q. How can I determine if my application is running on a Tablet PC?
A. Use the Windows GetSystemMetrics API and pass in SM_TABLETPC as the
value
of the index. SM_TABLETPC is defined in Winuser.h. The value of
SM_TABLETPC
is 86. The method returns True or nonzero if the Microsoft Windows XP
Tablet
PC Edition operating system is running; False or zero otherwise.

Applications should not rely on a true or nonzero value to mean all
Tablet
PC components are installed and working. See the following question for
details on how to determine if Tablet PC components are installed.

</quote>

There is also a MediaCenter system metrics value.

I would expect System.Windows.Forms.SystemInformation would list both
values
as it gives most other SystemMetrics, however it appears to be missing
TabletPC (SM_TABLETPC) & MediaCenter (SM_MEDIACENTER).

You can use code similar to:

Public Enum SystemMetric As Integer
TabletPC = 86
MediaCenter = 87
End Enum

Declare Auto Function GetSystemMetrics Lib "User32" (ByVal index As
SystemMetric) As Integer

If GetSystemMetrics(SystemMetric.TabletPC) <> 0 Then
Debug.WriteLine("On a Tablet PC")
Else
Debug.WriteLine("Not on a Tablet PC")
End If

If GetSystemMetrics(SystemMetric.MediaCenter ) <> 0 Then
Debug.WriteLine("On a Media Center PC")
Else
Debug.WriteLine("Not on a Media Center PC")
End If

I've used the Tablet PC value reliably, I don't have a Media Center PC to
verify the Media Center value.

I'm not sure how to tell the difference between Home & Pro.

Hope this helps
Jay


--
Hope this helps
Jay [MVP - Outlook]
T.S. Bradley - http://www.tsbradley.net


"ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| Thanks, but it gives me the version of windows running, 95, 98, 2000,
xp,
| 2003, etc, but it doesn't tell me if the Windows edition is server or
| workstation, even the build numbers are the same for both(if I'm not
| mistaken). Whether it is win9x, 2000, xp or 2003 doesn't matter to me,
I
| just want to know if it's workstation(or home, or pro) or server.
|
| Is there another way to know? (by a method, a property or even a
registry
| key)
|
| Thanks
|
| "Jay B. Harlow [MVP - Outlook]" <[email protected]> a écrit
dans
| le message de [email protected]...
| > ThunderMusic,
| > Have you looked at System.Environment.OSVersion?
| >
| > For details see:
| > http://support.microsoft.com/kb/304289
| >
| >
| > --
| > Hope this helps
| > Jay [MVP - Outlook]
| > T.S. Bradley - http://www.tsbradley.net
| >
| >
| > "ThunderMusic" <NO.danlat.at.hotmail.com.SPAM> wrote in message
| > | > | Hi,
| > | How can I get if the Windows running is a server version?
| > |
| > | Is there a property somewhere that can tell me if the Windows
version
is
| > a
| > | server edition (including server, advanced server, web server, etc)
or
| > just
| > | a workstation (if it's not a workstation, then it's a server). My
app
| > must
| > | verifies that for security reasons. It should work from at least
windows
| > | 2000 (Windows 98 and ME, would appreciated to, but if it's not
possible,
| > | I'll put it in the system requirements)
| > |
| > | Thanks
| > |
| > | ThunderMusic
| > |
| > |
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top