Identify Xp home vs pro

I need to be able to identify XP home vs pro in vb6.

I want to use an API or Reg entry not WMI.  Any ideas and source code.

I tried the platford id but doesnt seem to show home vs pro just xp in general.

thanks scott
ocsscottAsked:
Who is Participating?
 
Anthony PerkinsConnect With a Mentor Commented:
You need to use the OSVERSIONINFOEX structure.

Here is an article that should help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/sysinfo_1o1e.asp

Notice that to see what version of XP you are running you can check the wSuiteMask:
VER_SUITE_PERSONAL  Windows XP Home Edition is installed.  

Anthony
0
 
robbertCommented:
Maybe this information is in the OS's Build number which can retrieved by calling GetVersionEx():

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type
Private Sub Form_Load()
    Dim OSInfo As OSVERSIONINFO, PId As String
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'KPDTeam@Allapi.net
    'Set the graphical mode to persistent
    Me.AutoRedraw = True
    'Set the structure size
    OSInfo.dwOSVersionInfoSize = Len(OSInfo)
    'Get the Windows version
    Ret& = GetVersionEx(OSInfo)
    'Chack for errors
    If Ret& = 0 Then MsgBox "Error Getting Version Information": Exit Sub
    'Print the information to the form
    Select Case OSInfo.dwPlatformId
        Case 0
            PId = "Windows 32s "
        Case 1
            PId = "Windows 95/98"
        Case 2
            PId = "Windows NT "
    End Select
    Print "OS: " + PId
    Print "Win version:" + str$(OSInfo.dwMajorVersion) + "." + LTrim(str(OSInfo.dwMinorVersion))
    Print "Build: " + str(OSInfo.dwBuildNumber)
End Sub
0
 
Anthony PerkinsCommented:
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
raizonCommented:
Here is a sample usage of the GetVersionEx function.

I got this from www.allapi.net and modified it to use OSVERSIONINFOEX.

I use this in one on my own apps and it works great.


Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFOEX) As Long
Const VER_PLATFORM_WIN32_NT = 2
Const VER_PLATFORM_WIN32_WINDOWS = 1
Const VER_PLATFORM_WIN32s = 0
Const VER_SUITE_BACKOFFICE = 4 'Microsoft BackOffice components are installed.
'Const VER_SUITE_BLADE 'Windows .NET Web Server is installed.
Const VER_SUITE_SMALLBUSINESS = 1 'Microsoft Small Business Server is installed.
Const VER_SUITE_ENTERPRISE = 2 'Windows 2000 Advanced Server or Windows .NET Enterprise Server is installed.
Const VER_SUITE_COMMUNICATIONS = 8
Const VER_SUITE_TERMINAL = 10 'Terminal Services is installed.
Const VER_SUITE_SMALLBUSINESS_RESTRICTED = 20 'Microsoft Small Business Server is installed with the restrictive client license in force.
Const VER_SUITE_EMBEDDEDNT = 40
Const VER_SUITE_DATACENTER = 80 'Windows 2000 or Windows .NET Datacenter Server is installed.
Const VER_SUITE_SINGLEUSERTS = 100
Const VER_SUITE_PERSONAL = 200  'Windows XP Home Edition is installed.
Const VER_SUITE_SERVERAPPLIANCE = 400
Const VER_NT_WORKSTATION = 1 'The system is running Windows NT 4.0 Workstation, Windows 2000 Professional, Windows XP Home Edition, or Windows XP Professional.
Const VER_NT_DOMAIN_CONTROLLER = 2 'The system is a domain controller.
Const VER_NT_SERVER = 3 'The system is a server.


Private Type OSVERSIONINFOEX
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
    wServicePackMajor As Integer
    wServicePackMinor As Integer
    wSuiteMask As Integer
    wProductType As Byte
    wReserved As Byte
End Type
Private Sub Form_Load()
    Dim OSInfo As OSVERSIONINFOEX, PId As String
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'KPDTeam@Allapi.net
    'Set the graphical mode to persistent
    Me.AutoRedraw = True
    'Set the structure size
    OSInfo.dwOSVersionInfoSize = Len(OSInfo)
    'Get the Windows version
    Ret& = GetVersionEx(OSInfo)
    'Chack for errors
    If Ret& = 0 Then MsgBox "Error Getting Version Information": Exit Sub
    'Print the information to the form
    Select Case OSInfo.dwPlatformId
        Case VER_PLATFORM_WIN32s
            PId = "Windows 32s "
        Case VER_PLATFORM_WIN32_WINDOWS
            PId = "Windows 95/98"
        Case VER_PLATFORM_WIN32_NT
            PId = "Windows NT "
    End Select
    Select Case OSInfo.wProductType
        Case VER_NT_WORKSTATION
            PType = "Workstation"
        Case VER_NT_DOMAIN_CONTROLLER
            PType = "Domain Controller"
        Case VER_NT_SERVER
            PType = "Server"
        Case Else
            PType = OSInfo.wProductType
    End Select
    Select Case OSInfo.wSuiteMask
        Case VER_SUITE_BACKOFFICE
            pSuite = "Microsoft BackOffice components are installed."
        'Case VER_SUITE_BLADE
        '    pSuite = "Windows .NET Web Server is installed."
        Case VER_SUITE_DATACENTER
            pSuite = "Windows 2000 or Windows .NET Datacenter Server is installed."
        Case VER_SUITE_ENTERPRISE
            pSuite = "Windows 2000 Advanced Server or Windows .NET Enterprise Server is installed."
        Case VER_SUITE_PERSONAL
            pSuite = "Windows XP Home Edition is installed."
        Case VER_SUITE_SMALLBUSINESS
            pSuite = "Microsoft Small Business Server is installed."
        Case VER_SUITE_SMALLBUSINESS_RESTRICTED
            pSuite = "Microsoft Small Business Server is installed with the restrictive client license in force."
        Case VER_SUITE_TERMINAL
            pSuite = "Terminal Services is installed"
        Case Else
            pSuite = "Standard Install"
    End Select
   
    Select Case OSInfo.dwMajorVersion
        Case 4
            Select Case OSInfo.dwPlatformId
                Case VER_PLATFORM_WIN32s
                Case VER_PLATFORM_WIN32_WINDOWS
                    Select Case OSInfo.dwMinorVersion
                        Case 0
                            sOS = "Windows 95"
                        Case 10
                            sOS = "Windows 98"
                        Case 90
                            sOS = "Windows ME"
                    End Select
                Case VER_PLATFORM_WIN32_NT
                    sOS = "Windows NT 4.0"
            End Select
        Case 3
            sOS = "Windows NT 3." & LTrim(Str(OSInfo.dwMinorVersion))
        Case 5
            Select Case OSInfo.dwMinorVersion
                Case 0
                    sOS = "Windows 2000"
                Case 1
                    sOS = "Windows XP"
            End Select
    End Select
           
    Print "OS: " + sOS
    Print "Win version:" + Str$(OSInfo.dwMajorVersion) + "." + LTrim(Str(OSInfo.dwMinorVersion)) + Str(OSInfo.dwBuildNumber)
    Print "Service Pack: " + Str$(OSInfo.wServicePackMajor) + "." + Str(OSInfo.wServicePackMinor)
    Print "Suite Pack: " + pSuite
    Print "Product Type: " + PType
End Sub

0
 
ocsscottAuthor Commented:
ok i also found all of these but what is the correct value for VER_SUITE_PERSONAL

the samples ive seen show 200 or 512 on my test machine it was 768

what gives any idea.

scott
0
 
Anthony PerkinsCommented:
VER_SUITE_PERSONAL = 0x00000200 = 512

Anthony
0
 
Anthony PerkinsCommented:
The wSuiteMask is a combination of flags.  In your case:
wSuiteMask = VER_SUITE_PERSONAL + VER_SUITE_SINGLEUSERTS
or
wSuiteMask = 0x00000200 + 0x00000100 = 768


Anthony
0
 
Anthony PerkinsCommented:
If all you want to do is check for VER_SUITE_PERSONAL than

If wSuiteMask And VER_SUITE_PERSONAL = VER_SUITE_PERSONAL Then
   ' Must be Windows XP Home Edition

Anthony
   
0
 
raizonCommented:
Thanks Anthony,

That does explain a few things for me.

0
 
raizonCommented:
These should work then.  

'Const VER_SUITE_BLADE 'Windows .NET Web Server is installed.
Const VER_SUITE_SMALLBUSINESS = &H1 'Microsoft Small Business Server is installed.
Const VER_SUITE_ENTERPRISE = &H2 'Windows 2000 Advanced Server or Windows .NET Enterprise Server is installed.
Const VER_SUITE_BACKOFFICE = &H4 'Microsoft BackOffice components are installed.
Const VER_SUITE_COMMUNICATIONS = &H8
Const VER_SUITE_TERMINAL = &H10 'Terminal Services is installed.
Const VER_SUITE_SMALLBUSINESS_RESTRICTED = &H20 'Microsoft Small Business Server is installed with the restrictive client license in force.
Const VER_SUITE_EMBEDDEDNT = &H40
Const VER_SUITE_DATACENTER = &H80 'Windows 2000 or Windows .NET Datacenter Server is installed.
Const VER_SUITE_SINGLEUSERTS = &H100
Const VER_SUITE_PERSONAL = &H200  'Windows XP Home Edition is installed.
Const VER_SUITE_SERVERAPPLIANCE = &H400
0
 
raizonCommented:
Oscott,

How is it going with this?
0
 
ocsscottAuthor Commented:
ok guys got it to work.   thanks to you all

looking at the thread i think anthony gets the points but everyone was of help.

thanks again.  My system having the problem returned a 768 a combination of

Const VER_SUITE_SINGLEUSERTS = &H100
Const VER_SUITE_PERSONAL = &H200  

scott
0
 
ocsscottAuthor Commented:
thanks again to you all.

scott
0
 
raizonCommented:
glad it works.

For your information

Windows XP Professional returns
VER_SUITE_SINGLEUSERTS = &H100
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.