Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: determine XP home verses XP pro using GetVersionEx API
I put some comments in the script explaining how to perform these tests.
; GetVersionEx.wbt ; 32-bit ; ; Calls the Win32 API function GetVersionEx() to obtain some extended operating system version data. ; ; Per the MSDN docs, GetVersionEx() only returns this extended information on Win2K and newer systems. ; So, the perfectly correct way to do this would be to call GetVersion() first and verify that we are ; running WinNT v5.0 or newer before attempting to get the suite mask information that is capable of ; distinguishing between WinXP Pro Edition and WinXP Home Edition. Here, we're playing it slightly ; sloppy by directly asking for extended information. Don't run this on WinNT v4.0 or older. Title01 = 'GetVersionEx() - Get Extended O.S. Version Data' hBuf = BinaryAlloc(156) if (!hBuf) Message(Title01,'Error! Unable to allocate a binary buffer. Aborting...') exit endif ; Stuff the buffer size into the first DWORD BinaryPoke4(hBuf,0,156) ; Set the end of data marker BinaryEodSet(hBuf,155) ; Get the extended version information Result = DllCall('KERNEL32.DLL',long:'GetVersionExA',lpbinary:hBuf) if (!Result) Message(Title01,'Error! DllCall() for "GetVersionExA()" failed. Aborting...') BinaryFree(hBuf) exit endif ; Now we can tear up the binary buffer and get all of the information out of it... MajorVersion = BinaryPeek4(hBuf,4) MinorVersion = BinaryPeek4(hBuf,8) BuildNumber = BinaryPeek4(hBuf,12) PlatformID = BinaryPeek4(hBuf,16) CSDVersion = BinaryPeekStr(hBuf,20,128) SPMajorVersion = BinaryPeek2(hBuf,148) SPMinorVersion = BinaryPeek2(hBuf,150) SuiteMask = BinaryPeek2(hBuf,152) ProductType = BinaryPeek(hBuf,154) TempMsg = StrCat('O.S. Major Version = ',MajorVersion) TempMsg = StrCat(TempMsg,@CRLF,'O.S. Minor Version = ',MinorVersion) TempMsg = StrCat(TempMsg,@CRLF,'O.S. Build Number = ',BuildNumber) TempMsg = StrCat(TempMsg,@CRLF,'Platform Id = ',PlatformID) TempMsg = StrCat(TempMsg,@CRLF,'CSD Version = "',CSDVersion,'"') TempMsg = StrCat(TempMsg,@CRLF,'Service Pack Major Version = ',SPMajorVersion) TempMsg = StrCat(TempMsg,@CRLF,'Service Pack Minor Version = ',SPMinorVersion) TempMsg = StrCat(TempMsg,@CRLF,'Suite Mask = ',SuiteMask) ; this is the really interesting field... TempMsg = StrCat(TempMsg,@CRLF,'Product Type = ',ProductType) Message(Title01,TempMsg) majorver = WinVersion(1) minorver = WinVersion(0) if platformid==2 && majorver==5 && minorver==1 && producttype==1 ;If the result of (VerSuite & 512) is non-zero then that indicates that WinXP Home Edition is ;being used. If (VerSuite & 512) is zero then WinXP Professional Edition is being used. if SuiteMask & 512 Message(Title01,"WinXP Home Edition") else Message(Title01,"WinXP Professional Edition") endif exit else Message(Title01,"Invalid platform to perform this test") endif exit ; The SuiteMask field is a bit masked value that identifies various types of functionality that are ; present: ; ; VER_SUITE_SMALLBUSINESS = 1 = 0x00000001 ; VER_SUITE_ENTERPRISE = 2 = 0x00000002 ; VER_SUITE_BACKOFFICE = 4 = 0x00000004 ; VER_SUITE_COMMUNICATIONS = 8 = 0x00000008 ; VER_SUITE_TERMINAL = 16 = 0x00000010 ; VER_SUITE_SMALLBUSINESS_RESTRICTED = 32 = 0x00000020 ; VER_SUITE_EMBEDDEDNT = 64 = 0x00000040 ; VER_SUITE_DATACENTER = 128 = 0x00000080 ; VER_SUITE_SINGLEUSERTS = 256 = 0x00000100 ; VER_SUITE_PERSONAL = 512 = 0x00000200 ; VER_SUITE_BLADE = 1024 = 0x00000400 ; ; The PERSONAL bit is enabled if XP Home Edition is being used. ; ; The TERMINAL bit is enabled if the system is capable of supporting multiple-user terminal ; services. ; ; The SINGLLEUSERTS bit is enabled if the system is capable of supporting the remote desktop ; functionality, which is just a very limited form of terminal services used for remote ; administration tasks. ; ; ; To test properly for any flavor of WinXP, the following must be true: ; ; The PlatformID must be 2 [NT platform family] ; The O.S. Major Version must be 5. ; The O.S. Minor Version must be 1. ; The Product Type must be 1 [workstation, not server] ; If the result of (VerSuite & 512) is non-zero then that indicates that WinXP Home Edition is ; being used. If (VerSuite & 512) is zero then WinXP Professional Edition is being used.
Article ID: W15485
File Created: 2003:05:16:14:43:52
Last Updated: 2003:05:16:14:43:52