Solved

How to detect Windows XP SP2 installed using VB6?

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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