473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Anyone Got A Function That Returns Which OS We're running on?

Siv
Hi,
Does anyone have a function that when called returns which operating system
we are running on. E.g:

Select Case GetOSVer()
Case 1 'Win95
...
Case 2 'Win98
...
Case 3 'Win98SE
...
Case 4 'WinME
...
Case 5 'WinNT4
...
Case 6 'Win2k
...
Case 7 'WinXP
...
End select

I'm sure I could figure out my own version, but why re-invent the wheel!

Siv
Nov 21 '05 #1
8 1536
Hi, try this....

Dim os As String
os = System.Environment.OSVersion.ToString
MsgBox(os)

there are a few diff options under OSVersion including platform etc, so you get look at the enum for the diff os's and use then platform number in your select.

Cheers
Adam

Nov 21 '05 #2
Try this;

Public Function GetOSVersion() As String
Select Case Environment.OSVersion.Platform
Case PlatformID.Win32S
Return "Win 3.1"
Case PlatformID.Win32Windows
Select Case Environment.OSVersion.Version.Minor
Case 0
Return "Win95"
Case 10
Return "Win98"
Case 90
Return "WinME"
Case Else
Return "Unknown"
End Select
Case PlatformID.Win32NT
Select Case Environment.OSVersion.Version.Major
Case 3
Return "NT 3.51"
Case 4
Return "NT 4.0"
Case 5
Select Case _
Environment.OSVersion.Version.Minor
Case 0
Return "Win2000"
Case 1
Return "WinXP"
Case 2
Return "Win2003"
End Select
Case Else
Return "Unknown"
End Select
Case PlatformID.WinCE
Return "Win CE"
End Select
End Function
--
Gerry O'Brien [MVP]
Visual Basic .NET(VB.NET)


"Siv" <gs@remove.sivill.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,
Does anyone have a function that when called returns which operating
system we are running on. E.g:

Select Case GetOSVer()
Case 1 'Win95
...
Case 2 'Win98
...
Case 3 'Win98SE
...
Case 4 'WinME
...
Case 5 'WinNT4
...
Case 6 'Win2k
...
Case 7 'WinXP
...
End select

I'm sure I could figure out my own version, but why re-invent the wheel!

Siv

Nov 21 '05 #3
Siv
Thanks Gerry,
This looks like just what I was after.
Siv

"Gerry O'Brien [MVP]" <gerry dot obrien at gmail dot com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Try this;

Public Function GetOSVersion() As String
Select Case Environment.OSVersion.Platform
Case PlatformID.Win32S
Return "Win 3.1"
Case PlatformID.Win32Windows
Select Case Environment.OSVersion.Version.Minor
Case 0
Return "Win95"
Case 10
Return "Win98"
Case 90
Return "WinME"
Case Else
Return "Unknown"
End Select
Case PlatformID.Win32NT
Select Case Environment.OSVersion.Version.Major
Case 3
Return "NT 3.51"
Case 4
Return "NT 4.0"
Case 5
Select Case _
Environment.OSVersion.Version.Minor
Case 0
Return "Win2000"
Case 1
Return "WinXP"
Case 2
Return "Win2003"
End Select
Case Else
Return "Unknown"
End Select
Case PlatformID.WinCE
Return "Win CE"
End Select
End Function
--
Gerry O'Brien [MVP]
Visual Basic .NET(VB.NET)


"Siv" <gs@remove.sivill.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,
Does anyone have a function that when called returns which operating
system we are running on. E.g:

Select Case GetOSVer()
Case 1 'Win95
...
Case 2 'Win98
...
Case 3 'Win98SE
...
Case 4 'WinME
...
Case 5 'WinNT4
...
Case 6 'Win2k
...
Case 7 'WinXP
...
End select

I'm sure I could figure out my own version, but why re-invent the wheel!

Siv


Nov 21 '05 #4
Siv
Thanks for that,
I will give it a try.
Siv
"Adam Maltby" <ad***@frfl.co.uk> wrote in message news:e2**************@TK2MSFTNGP11.phx.gbl...
Hi, try this....

Dim os As String
os = System.Environment.OSVersion.ToString
MsgBox(os)

there are a few diff options under OSVersion including platform etc, so you get look at the enum for the diff os's and use then platform number in your select.

Cheers
Adam

Nov 21 '05 #5
Siv
It did work brilliantly, thanks Gerry.
Siv

"Siv" <gs@remove.sivill.com> wrote in message
news:eB**************@TK2MSFTNGP10.phx.gbl...
Thanks Gerry,
This looks like just what I was after.
Siv

"Gerry O'Brien [MVP]" <gerry dot obrien at gmail dot com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Try this;

Public Function GetOSVersion() As String
Select Case Environment.OSVersion.Platform
Case PlatformID.Win32S
Return "Win 3.1"
Case PlatformID.Win32Windows
Select Case Environment.OSVersion.Version.Minor
Case 0
Return "Win95"
Case 10
Return "Win98"
Case 90
Return "WinME"
Case Else
Return "Unknown"
End Select
Case PlatformID.Win32NT
Select Case Environment.OSVersion.Version.Major
Case 3
Return "NT 3.51"
Case 4
Return "NT 4.0"
Case 5
Select Case _
Environment.OSVersion.Version.Minor
Case 0
Return "Win2000"
Case 1
Return "WinXP"
Case 2
Return "Win2003"
End Select
Case Else
Return "Unknown"
End Select
Case PlatformID.WinCE
Return "Win CE"
End Select
End Function
--
Gerry O'Brien [MVP]
Visual Basic .NET(VB.NET)


"Siv" <gs@remove.sivill.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi,
Does anyone have a function that when called returns which operating
system we are running on. E.g:

Select Case GetOSVer()
Case 1 'Win95
...
Case 2 'Win98
...
Case 3 'Win98SE
...
Case 4 'WinME
...
Case 5 'WinNT4
...
Case 6 'Win2k
...
Case 7 'WinXP
...
End select

I'm sure I could figure out my own version, but why re-invent the wheel!

Siv



Nov 21 '05 #6

"Siv" <gs@remove.sivill.com> wrote in message
news:OT*************@TK2MSFTNGP11.phx.gbl...
It did work brilliantly, thanks Gerry.


For completeness, people have asked in the past if it's possible to
distinguish between different "flavors" of XP, like Home, Pro, Tablet, and
Media Center. I haven't seen a satisfactory solution to that one yet.
Nov 21 '05 #7
Jeff,
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

"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:Ol**************@tk2msftngp13.phx.gbl...

"Siv" <gs@remove.sivill.com> wrote in message
news:OT*************@TK2MSFTNGP11.phx.gbl...
It did work brilliantly, thanks Gerry.


For completeness, people have asked in the past if it's possible to
distinguish between different "flavors" of XP, like Home, Pro, Tablet, and
Media Center. I haven't seen a satisfactory solution to that one yet.

Nov 21 '05 #8

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I've used the Tablet PC value reliably, I don't have a Media Center PC to
verify the Media Center value.
I may check it at home if I get the urge. Media Center rocks, by the way.
I'm not sure how to tell the difference between Home & Pro.


Now if only I can find the thread I saw where no one had a good answer to
this question I can give them yours.... (I think it was a different group.)
Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kayodeok | last post by:
We're Mad As Hell And We're Not Going To Take It Anymore http://hownow.brownpau.com/index.html The web is a mess. We're tired of this deluge of <font> tags, nested tables, spacer GIFs, and...
2
by: Leveridge Systems INC | last post by:
We're in desperate need of contract help for c++/ linux or Unix based talent. 6 month need .. we have budget for a serious coder.. so the dollars are there. anyways.. may be of help to a...
2
by: Yeounkun, Oh | last post by:
Hello, I want to know the name of function() in program. In "gcc", I know that __FUNCTION__ macro is used for getting that. but in "cc", __FUNCTION__ macro does not exist. I can't find function...
4
by: ImOk | last post by:
I have the following setup: Windows XP Prof, IIS, PHP5 PHP5 works no problem with either PHP-CGI.EXE and mySQL, PHP5 also works no problem with php5isapi.dll as long as I dont use mySQL....
0
by: Dale Strickland-Clark | last post by:
I'll keep this brief. Please see the web site for details Thanks. -- Dale Strickland-Clark We are recruiting Python programmers. Please see the web site. Riverhall Systems www.riverhall.co.uk
6
by: Saber | last post by:
Is there a way to find out in which mode we are? What can I write instead of "ItIsDebugMode" in this condition? if (ItIsDebugMode) { //write something in somefile }
0
by: fiansdf.illlll | last post by:
sha nd we're all this in tgother
4
by: Kristof Coucke | last post by:
Hello, I've got a question related to an embedded IE object. My webpage (simple HTML) is shown inside another application which uses an IE object (not a separate window, but embedded). This...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.