* Program....: GETWINVER.PRG
* Author.....: ** Richard G Bean **
* Date.......: April 3, 2000
* Changed on 01/31/02 - Extended for XP+
&& Don't currently use all these DEFINEs, but could if want to explore 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
* Program....: ASC2BEINT.PRG
* Author.....: ** Richard G Bean **
* Date.......: April 3, 2000
* Abstract...: Ascii String to BigEndian Integer (i.e. Most significant byte on right)
* (use asc2int() for LittleEndian)
* Doesn't return negative numbers
* RETURN -1 if any error
* Changes....:
*FUNCTION asc2BEint
LPARAMETERS p_cString, p_nStart, p_nLength
IF PCOUNT() < 1 OR VARTYPE(p_cString) <> "C"
RETURN -1
ENDIF
IF PCOUNT() < 2 OR VARTYPE(p_nStart) <> "N"
p_nStart = 1
ENDIF
IF PCOUNT() < 3 OR VARTYPE(p_nLength) <> "N"
p_nLength = LEN(p_cString)
ENDIF
LOCAL lnRet_val
DO CASE
CASE p_nLength = 1
lnRet_val = asc(SUBSTR(p_cString, p_nStart, 1))
CASE p_nLength = 2
lnRet_val = asc(SUBSTR(p_cString, p_nStart, 1));
+ asc(SUBSTR(p_cString, p_nStart+1, 1))*256
CASE p_nLength = 3
lnRet_val = asc(SUBSTR(p_cString, p_nStart, 1));
+ asc(SUBSTR(p_cString, p_nStart+1, 1))*256;
+ asc(SUBSTR(p_cString, p_nStart+2, 1))*256^2
CASE p_nLength = 4
lnRet_val = asc(SUBSTR(p_cString, p_nStart, 1));
+ asc(SUBSTR(p_cString, p_nStart+1, 1))*256;
+ asc(SUBSTR(p_cString, p_nStart+2, 1))*256^2;
+ asc(SUBSTR(p_cString, p_nStart+3, 1))*256^3
OTHERWISE
lnRet_val = -1
ENDCASE
RETURN INT(lnRet_val)
*!* EOP: ASC2BEINT.PRG