Solved

How to detect Windows XP SP2 installed using VB6?

Posted on 2004-10-09
4
1,406 Views
Last Modified: 2008-02-26
How does my VB6 application detect if the application is running on a machine that has Windows XP SP2 installed?
0
Comment
Question by:samuel999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:Shahid Thaika
ID: 12269441
I don't have SP2 installed on my system. But if SP2 is installed on any system, a value will be entered in the registry. You just have to check for this value. If it is true, then SP2 is installed.

Service Pack 1 entry is saved in...
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion (BuildLab) or (CSDVersion)

If you have SP2 installed, you can try searching for the value 'Service Pack 2' or SP2 in your registry

Hope this answer helps you :)
0
 
LVL 9

Expert Comment

by:Shahid Thaika
ID: 12269452
Oh incase you don't know how to read a value from the registry, here is a nice tutorial...
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=1881
0
 

Expert Comment

by:jrolson
ID: 12271833
This code might help you.
It will find the version of Windows.

Module Code
Public Type OSVERSIONINFOEX
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

Public Const VER_PLATFORM_WIN32s = 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2

Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long

Form Code
Public Function OSVersion() As String
   
    Dim udtOSVersion As OSVERSIONINFOEX
    Dim lMajorVersion  As Long
    Dim lMinorVersion As Long
    Dim lPlatformID As Long
    Dim sAns As String
   
   
    udtOSVersion.dwOSVersionInfoSize = Len(udtOSVersion)
    GetVersionEx udtOSVersion
    lMajorVersion = udtOSVersion.dwMajorVersion
    lMinorVersion = udtOSVersion.dwMinorVersion
    lPlatformID = udtOSVersion.dwPlatformId
   
    Select Case lMajorVersion
        Case 5
            sAns = "Windows 2000"
        Case 4
            If lPlatformID = VER_PLATFORM_WIN32_NT Then
                sAns = "Windows NT 4.0"
            Else
                sAns = IIf(lMinorVersion = 0, _
                "Windows 95", "Windows 98")
            End If
        Case 3
            If lPlatformID = VER_PLATFORM_WIN32_NT Then
                sAns = "Windows NT 3.x"
            Else
                sAns = "Windows 3.x"
            End If
           
        Case Else
            sAns = "Unknown Windows Version"
    End Select
                   
    OSVersion = sAns
   
End Function

Private Sub Form_Load()
     MsgBox "Windows version detected: " & OSVersion
End Sub
0
 
LVL 4

Accepted Solution

by:
AjithJose earned 50 total points
ID: 12272021
In the above code in type OSVERSIONINFOEX structure, szCSDVersion will contain the Service Pack installed

Try following code in a module

Public Type OSVERSIONINFOEX
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

Public Const VER_PLATFORM_WIN32s = 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2

Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long

Form Code
Public Function GetInstalledServicePack() As String
   
    Dim udtOSVersion As OSVERSIONINFOEX
    Dim lPlatformID As Long
   
   
    udtOSVersion.dwOSVersionInfoSize = Len(udtOSVersion)
    GetVersionEx udtOSVersion

    lPlatformID = udtOSVersion.dwPlatformId

    If lPatrformID  =VER_PLATFORM_WIN32_NT then
           GetInstalledServicePack=udtOSVersion.szCSDVersion
    end if

End Function
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question