PC Review


Reply
Thread Tools Rate Thread

Detecting which Windows is running

 
 
avi
Guest
Posts: n/a
 
      14th Jun 2008
Hello,

Is there a simple way to know programatically if the user's computer
runs Vista or XP?

Thanks a lot
Avi
 
Reply With Quote
 
 
 
 
RB Smissaert
Guest
Posts: n/a
 
      14th Jun 2008
Haven't tested on Vista as I don't have it, but see what this shows:

Option Explicit
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As
OSVERSIONINFO) As Long

Function getWindowsVersion() As String

Dim TheOS As OSVERSIONINFO
Dim strCSDVersion As String

TheOS.dwOSVersionInfoSize = Len(TheOS)
GetVersionEx TheOS

Select Case TheOS.dwPlatformId
Case VER_PLATFORM_WIN32_WINDOWS
If TheOS.dwMinorVersion >= 10 Then
getWindowsVersion = "Windows 98 version: "
Else
getWindowsVersion = "Windows 95 version: "
End If
Case VER_PLATFORM_WIN32_NT
getWindowsVersion = "Windows NT version: "
End Select

'Extract the Additional Version Information from
'the string with null char terminator
If InStr(TheOS.szCSDVersion, Chr(0)) <> 0 Then
strCSDVersion = ": " & Left$(TheOS.szCSDVersion, _
InStr(TheOS.szCSDVersion, Chr(0)) - 1)
Else
strCSDVersion = ""
End If

getWindowsVersion = getWindowsVersion & TheOS.dwMajorVersion & "." & _
TheOS.dwMinorVersion & _
" (Build " & TheOS.dwBuildNumber & strCSDVersion & ")"

End Function


Sub test()

MsgBox getWindowsVersion(), , "Windows version"

End Sub


RBS


"avi" <(E-Mail Removed)> wrote in message
news:2675af02-220f-42de-8366-(E-Mail Removed)...
> Hello,
>
> Is there a simple way to know programatically if the user's computer
> runs Vista or XP?
>
> Thanks a lot
> Avi


 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      14th Jun 2008
Hi,

This reports it correctly on mine but not tested on other systems

mysystem = Environ(13)

Mike

"avi" wrote:

> Hello,
>
> Is there a simple way to know programatically if the user's computer
> runs Vista or XP?
>
> Thanks a lot
> Avi
>

 
Reply With Quote
 
Leith Ross
Guest
Posts: n/a
 
      14th Jun 2008
On Jun 14, 11:16 am, Mike H <Mi...@discussions.microsoft.com> wrote:
> Hi,
>
> This reports it correctly on mine but not tested on other systems
>
> mysystem = Environ(13)
>
> Mike
>
> "avi" wrote:
> > Hello,

>
> > Is there a simple way to know programatically if the user's computer
> > runs Vista or XP?

>
> > Thanks a lot
> > Avi


Hello Avi,

Another method is to use "Application.Version". Xp returns "11.0", and
Vista "12.0"

Sincerely,
Leith Ross
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      14th Jun 2008
I bet you meant: Application.OperatingSystem

Application.version will give the version of excel (11 is xl2003, 12 is xl2007
(I bet)).



Leith Ross wrote:
>

<<snipped>>
>
> Another method is to use "Application.Version". Xp returns "11.0", and
> Vista "12.0"
>
> Sincerely,
> Leith Ross


--

Dave Peterson
 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      14th Jun 2008
Thanks for the tip; nice and simple.

RBS


"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I bet you meant: Application.OperatingSystem
>
> Application.version will give the version of excel (11 is xl2003, 12 is
> xl2007
> (I bet)).
>
>
>
> Leith Ross wrote:
>>

> <<snipped>>
>>
>> Another method is to use "Application.Version". Xp returns "11.0", and
>> Vista "12.0"
>>
>> Sincerely,
>> Leith Ross

>
> --
>
> Dave Peterson


 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      15th Jun 2008
If it helps any, on my 32-bit Vista Ultimate Edition system,
Application.OperatingSystem returns this...

Windows (32-bit) NT 6.00

Rick


"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I bet you meant: Application.OperatingSystem
>
> Application.version will give the version of excel (11 is xl2003, 12 is
> xl2007
> (I bet)).
>
>
>
> Leith Ross wrote:
>>

> <<snipped>>
>>
>> Another method is to use "Application.Version". Xp returns "11.0", and
>> Vista "12.0"
>>
>> Sincerely,
>> Leith Ross

>
> --
>
> Dave Peterson


 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      15th Jun 2008
If you run it on 64 bit system it return also 32 bit

I have report this bug

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Rick Rothstein (MVP - VB)" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> If it helps any, on my 32-bit Vista Ultimate Edition system,
> Application.OperatingSystem returns this...
>
> Windows (32-bit) NT 6.00
>
> Rick
>
>
> "Dave Peterson" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I bet you meant: Application.OperatingSystem
>>
>> Application.version will give the version of excel (11 is xl2003, 12 is
>> xl2007
>> (I bet)).
>>
>>
>>
>> Leith Ross wrote:
>>>

>> <<snipped>>
>>>
>>> Another method is to use "Application.Version". Xp returns "11.0", and
>>> Vista "12.0"
>>>
>>> Sincerely,
>>> Leith Ross

>>
>> --
>>
>> Dave Peterson

>

 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      15th Jun 2008
It is always better to use the Set variable name instead of its location in
the list (which could be different between different computers). For the
operating system, that would be 'OS' as in...

mysystem = Environ("OS")

However, this only return Windows_NT whereas the Application.OperatingSystem
statement mentioned elsewhere in this thread returns this..

Windows (32-bit) NT 6.00

which contains a little extra information. By the way, if you ever want to
see the various variable (names, for use in the Environ statement, and
settings), bring up a Command Prompt window (found in All Programs,
Accessories I think), type SET and hit the Enter key.

Rick


"Mike H" <(E-Mail Removed)> wrote in message
news:C4CD86EA-4372-4B11-8338-(E-Mail Removed)...
> Hi,
>
> This reports it correctly on mine but not tested on other systems
>
> mysystem = Environ(13)
>
> Mike
>
> "avi" wrote:
>
>> Hello,
>>
>> Is there a simple way to know programatically if the user's computer
>> runs Vista or XP?
>>
>> Thanks a lot
>> Avi
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting running application tc Microsoft VB .NET 2 9th Dec 2008 01:40 AM
Detecting that a program is already running Joecx Microsoft Dot NET 6 5th Sep 2004 09:37 PM
Detecting that a program is already running Joecx Microsoft VB .NET 7 27th Aug 2004 11:34 AM
Detecting Running Applications PeterM Microsoft Access Form Coding 2 23rd Apr 2004 06:38 PM
Detecting if running in VS.NET ko Microsoft Dot NET Framework 4 11th Sep 2003 10:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:49 AM.