Solved

Identify Xp home vs pro

Posted on 2002-05-09
14
303 Views
Last Modified: 2011-10-03
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
0
Comment
Question by:ocsscott
  • 5
  • 5
  • 3
  • +1
14 Comments
 
LVL 15

Expert Comment

by:robbert
Comment Utility
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
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 100 total points
Comment Utility
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
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
0
 
LVL 5

Expert Comment

by:raizon
Comment Utility
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
 

Author Comment

by:ocsscott
Comment Utility
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
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
VER_SUITE_PERSONAL = 0x00000200 = 512

Anthony
0
 
LVL 75

Expert Comment

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


Anthony
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
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
 
LVL 5

Expert Comment

by:raizon
Comment Utility
Thanks Anthony,

That does explain a few things for me.

0
 
LVL 5

Expert Comment

by:raizon
Comment Utility
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
 
LVL 5

Expert Comment

by:raizon
Comment Utility
Oscott,

How is it going with this?
0
 

Author Comment

by:ocsscott
Comment Utility
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
 

Author Comment

by:ocsscott
Comment Utility
thanks again to you all.

scott
0
 
LVL 5

Expert Comment

by:raizon
Comment Utility
glad it works.

For your information

Windows XP Professional returns
VER_SUITE_SINGLEUSERTS = &H100
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now