Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Function to determine versions of Windows XP
Message
From
07/02/2002 15:47:03
 
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00616673
Message ID:
00616980
Views:
23
This message has been marked as the solution to the initial question of the thread.
I've recently updated my version of a getwinver() function that includes this feature. It uses the new extended version of GetVersionEx.

Rick
* Program....: GETWINVER.PRG
* Version....: 1.0
* Author.....: ** Richard G Bean **
* Date.......: April 3, 2000
* Notice.....: ** Melange Computer Services, Inc **
* Compiler...: Visual FoxPro 06.00.8492.00 for Windows
* ** RGB ** changed on 01/31/02 -  Extended for XP+

&& Don't currently use all these DEFINEs, but could if we want to explore all 
&&  the Server Versions

#DEFINE VER_PLATFORM_WIN32S 0
#DEFINE VER_PLATFORM_WIN32_WINDOWS 1
#DEFINE VER_PLATFORM_WIN32_NT 2

#DEFINE VER_SERVER_NT                       0x80000000
#DEFINE VER_WORKSTATION_NT                  0x40000000

#DEFINE VER_NT_WORKSTATION		    0x00000001
#DEFINE VER_NT_DOMAIN_CONTROLLER	    0x00000002
#DEFINE VER_NT_SERVER               	    0x00000003

#DEFINE VER_SUITE_SMALLBUSINESS             0x00000001
#DEFINE VER_SUITE_ENTERPRISE                0x00000002
#DEFINE VER_SUITE_BACKOFFICE                0x00000004
#DEFINE VER_SUITE_COMMUNICATIONS            0x00000008
#DEFINE VER_SUITE_TERMINAL                  0x00000010
#DEFINE VER_SUITE_SMALLBUSINESS_RESTRICTED  0x00000020
#DEFINE VER_SUITE_EMBEDDEDNT                0x00000040
#DEFINE VER_SUITE_DATACENTER                0x00000080
#DEFINE VER_SUITE_SINGLEUSERTS              0x00000100
#DEFINE VER_SUITE_PERSONAL                  0x00000200
#DEFINE VER_SUITE_BLADE                     0x00000400

#DEFINE FFFF    			  0x0000FFFF && 65535

Declare LONG GetVersionEx in WIN32API STRING

STORE 0 to;
	 dwOSVersionInfoSize,;
    dwMajorVersion,;
    dwMinorVersion,;
    dwBuildNumber,;
    dwPlatformId,;
 	 wServicePackMajor,;
	 wServicePackMinor,;
	 wSuiteMask,;
	 wProductType,;
	 wReserved
    
szCSDVersion = ""
PId = "(Unknown)"

lczStructure = chr(5*4+127+1+3*2+2*1)+replicate(chr(0), 5*4-1)+;
               space(127)+chr(0)+replicate(chr(0), 3*2+2*1)

lcReturn = ""
lnResult = GetVersionEx( @lczStructure )
IF lnResult <> 0	&& No Error
	dwOSVersionInfoSize = asc2BEint(lczStructure, 1, 4)
	dwMajorVersion = asc2BEint(lczStructure, 5, 4)
	dwMinorVersion = asc2BEint(lczStructure, 9, 4)
	dwBuildNumber = BITAND(asc2BEint(lczStructure, 13, 4), FFFF)
	dwPlatformId = asc2BEint(lczStructure, 17, 4)
	szCSDVersion = ALLTRIM(CHRTRAN(SUBSTR(lczStructure, 21, 128),;
                       CHR(0)+CHR(1),""))
	IF dwOSVersionInfoSize > 148
		wServicePackMajor = asc2BEint(lczStructure, 149, 2)
		wServicePackMinor = asc2BEint(lczStructure, 151, 2)
		wSuiteMask = asc2BEint(lczStructure, 153, 2)
		wProductType = ASC(SUBSTR(lczStructure, 155, 1))
		wReserved = ASC(SUBSTR(lczStructure, 156, 1))
	ENDIF

	DO Case
	Case dwPlatformId = VER_PLATFORM_WIN32S
	    PId = "32s " 	&& "Windows 32s "
		
	Case dwPlatformId = VER_PLATFORM_WIN32_WINDOWS
	    PId = "95/98 " && "Windows 95/98 "
		DO CASE
		CASE dwMajorVersion = 4  and dwMinorVersion = 0
		   PId = "95 " && "Windows 95 "
		   lcSubVer = SUBSTR(szCSDVersion, 1, 1)
		   IF INLIST(lcSubVer, "B", "C")
		   	PId = PId + "OSR2 "
		   ENDIF
		CASE dwMajorVersion = 4  and dwMinorVersion = 10
		   PId = "98 " && "Windows 98 "
		   lcSubVer = SUBSTR(szCSDVersion, 1, 1)
		   IF lcSubVer = "A"
		   	PId = PId + "SE "
		   ENDIF
		CASE dwMajorVersion = 4  and dwMinorVersion = 90
		   PId = "ME " && "Windows ME "
		ENDCASE
		
	Case dwPlatformId = VER_PLATFORM_WIN32_NT
	    PId = "NT "			&& "Windows NT "
		DO CASE
		CASE dwMajorVersion <=  4
		   PId = "NT "			&& "Windows NT "
		   
		CASE dwMajorVersion = 5 and dwMinorVersion = 0
		   PId = "2000 "		&& "Windows 2000 "
		   
		CASE dwMajorVersion = 5 and dwMinorVersion = 1
		   PId = "XP "		&& "Windows XP "
		   IF BITAND(wSuiteMask, VER_SUITE_PERSONAL) <> 0
		   	PId = PId + "Home "
		   ELSE
		   	PId = PId + "Pro "
		   ENDIF
		ENDCASE
	ENDCASE
	
	lcReturn = PId ;
		+ ALLTRIM(transform(dwMajorVersion,"99999"));
		+ "." + ALLTRIM(transform(dwMinorVersion,"99999"));
		+ " (Build "+ ALLTRIM(transform(dwBuildNumber,"99999"));
		+ ":"+ IIF(EMPTY(szCSDVersion),"No SP", szCSDVersion);
		+ ")"
ENDIF

RETURN lcReturn

*!* EOP: GETWINVER.PRG
>Hi all,
> I am trying to determine which version of Windows XP, Professional or Home, is running on a workstation programmatically. Is that any function to do this?
>
> TIA.
>
>
>Wan
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform