Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File to tell Windows Version 2

Status
Not open for further replies.
Oct 25, 2001
103
US
Hello All-

I don't know if this is the best place to post this question, but is there a file with windows where I could look at it to see what version of windows someone is running? I would like to have a program decifer this file to see what version of Windows someone is running. My company has problems with different types of windows applying updates to their program. They have a couple of files that have to change directories, and if there was a way to see what version of Windows someone is running, we could just move those files and save the customers from calling in to fix the problem. Any help is apprecaited. Like I said, this may not be the best place to post this, as I may need to post it in a different forum, but maybe someone has the answer.

Thanks. Jason Wichman
ftp://jwichman.ath.cx:22
 
Option Explicit

'API Structures
Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

'API Calls:
Public Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

'API Constants
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2


Put in a module:
'get a string with the description of the operating system
Public 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 = &quot;: &quot; & Left(TheOS.szCSDVersion, InStr(TheOS.szCSDVersion, Chr(0)) - 1)
Else
strCSDVersion = &quot;&quot;
End If
GetWindowsVersion = GetWindowsVersion & TheOS.dwMajorVersion & &quot;.&quot; & TheOS.dwMinorVersion & &quot; (Build &quot; & TheOS.dwBuildNumber & strCSDVersion & &quot;)&quot;
End Function

Usage:

Private Sub Command1_Click()
MsgBox GetWindowsVersion
End Sub
 
Consider the SysInfo control, which has OSBuild, OSPlatform and OSVersion properties.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top