Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
avi avi is offline
external usenet poster
 
Posts: 195
Default Detecting which Windows is running

Hello,

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

Thanks a lot
Avi
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Detecting which Windows is running

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" wrote in message
...
Hello,

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

Thanks a lot
Avi


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Detecting which Windows is running

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Detecting which Windows is running

On Jun 14, 11:16 am, Mike H 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Detecting which Windows is running

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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Detecting which Windows is running

Thanks for the tip; nice and simple.

RBS


"Dave Peterson" wrote in message
...
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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Detecting which Windows is running

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" wrote in message
...
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


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Detecting which Windows is running

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)" wrote in message ...
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" wrote in message
...
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


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Detecting which Windows is running

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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide all windows while macro is running John Bundy Excel Programming 0 December 27th 06 03:13 PM
i have two windows xp running on my pc and seem to con flict with custer Excel Discussion (Misc queries) 1 November 21st 05 09:30 PM
Detecting if workbook running in IE or in Excel SkylineGTR Excel Programming 5 November 13th 05 01:20 AM
Running windows command from a VB code saurabhb[_2_] Excel Programming 0 September 16th 04 12:55 PM
running windows system commands in VBA tomek Excel Programming 1 February 5th 04 12:36 PM


All times are GMT +1. The time now is 11:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"