Solved

How to detect Windows XP SP2 installed using VB6?

Posted on 2004-10-09
4
1,408 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month5 days, 17 hours left to enroll

627 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