Page 1 of 1

OS Version

Posted: Tue Jul 26, 2011 1:09 pm
by IdeasVacuum
Using this (from the help) to get the OS version:

Code: Select all

Procedure.s GetOsVersn()
;----------------------

      sVersion.s = ""

      Select OSVersion()

            Case #PB_OS_Windows_NT3_51:       sVersion = "Windows NT3.51"
            Case #PB_OS_Windows_95:           sVersion = "Windows 95"
            Case #PB_OS_Windows_NT_4:         sVersion = "Windows NT4"
            Case #PB_OS_Windows_98:           sVersion = "Windows 98"
            Case #PB_OS_Windows_ME:           sVersion = "Windows ME"
            Case #PB_OS_Windows_2000:         sVersion = "Windows 2000"
            Case #PB_OS_Windows_XP:           sVersion = "Windows XP"
            Case #PB_OS_Windows_Server_2003:  sVersion = "Windows Server 2003"
            Case #PB_OS_Windows_Vista:        sVersion = "Windows Vista"
            Case #PB_OS_Windows_Server_2008:  sVersion = "Windows Server 2008"
            Case #PB_OS_Windows_7:            sVersion = "Windows 7"
            Case #PB_OS_Windows_Future:       sVersion = "Windows Version later than Win7"
            Default:                          sVersion = "Windows Version not identified"

      EndSelect

      ProcedureReturn sVersion

EndProcedure
.....and looking up a registry key to determine OS bits:

Code: Select all

Procedure.s OSbits()
;-------------------

      lpftLastWriteTime.FILETIME
             lpName.s = ""
           sKeyName.s = "Software\Wow6432Node"
            sOSbits.s = "64"
            sSubKey.s = ""
             iIndex.i = 1
               hKey.i = 0
          GetHandle.l = 0

      If Left(sKeyName, 1) = ""

              sKeyName = Right(sKeyName, Len(sKeyName) - 1)
      EndIf


         GetHandle = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, sKeyName, 0, #KEY_ALL_ACCESS, @hKey)

      If GetHandle = #ERROR_SUCCESS

                  lpcbName = 255
                    lpName = Space(255)

                 GetHandle = RegEnumKeyEx_(hKey, iIndex, @lpName, @lpcbName, 0, 0, 0, @lpftLastWriteTime)

              If GetHandle = #ERROR_SUCCESS : sSubKey = Left(lpName, lpcbName) : EndIf
      EndIf

      RegCloseKey_(hKey)

      If sSubKey = "" : sOSbits = "32" : EndIf

      ProcedureReturn sOSbits

EndProcedure
.... works perfectly but it's not enough. I really need to confirm that the PC has the latest OS Service Pack installed. Where is the most reliable place to find that info?

Re: OS Version

Posted: Tue Jul 26, 2011 1:23 pm
by moogle
IdeasVacuum wrote: .... works perfectly but it's not enough. I really need to confirm that the PC has the latest OS Service Pack installed. Where is the most reliable place to find that info?
Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

There are lots of variables in there that can verify it.

Re: OS Version

Posted: Tue Jul 26, 2011 1:29 pm
by IdeasVacuum
Thanks Moogle, I will take a look.

Also found this structure, which works well:

Code: Select all

OSVerInfo.OSVERSIONINFOEX

OSVerInfo\dwOSVersionInfoSize = SizeOf(OSVERSIONINFOEX) 

GetVersionEx_(@OSVerInfo)

Debug OSVerInfo\dwMajorVersion
Debug OSVerInfo\dwMinorVersion
Debug OSVerInfo\dwBuildNumber
Debug OSVerInfo\dwPlatformId
Debug OSVerInfo\wServicePackMajor
Debug OSVerInfo\wServicePackMinor

Re: OS Version

Posted: Tue Jul 26, 2011 1:34 pm
by moogle
Ahh yes that is a better way as the registry can be modified.

Also if you want to verify it have a look at

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

and

http://msdn.microsoft.com/en-us/library ... 85%29.aspx

Which have good example code (C++ but easy to understand) that you could use.