1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
| * Program....: GETWINVER.PRG
* Version....: 1.0
* Author.....: ** Richard G Bean **
* Date.......: April 3, 2000
* Compiler...: Visual FoxPro 06.00.8492.00 for Windows
* ** RGB ** changed on 01/31/02 - Extended for XP+
* ** RGB ** changed on 10/06/05 - Extended for 2003, Vista
* ** RGB ** changed on 05/24/08 - Extended for 2008 and Product Type for v6.0 +
* ** RGB ** changed on 02/22/09 - Extended for Windows 7
* Based on MSDN KB Article Q188987
&& 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 INT(0) to;
dwOSVersionInfoSize,;
dwMajorVersion,;
dwMinorVersion,;
dwBuildNumber,;
dwPlatformId,;
wServicePackMajor,;
wServicePackMinor,;
wSuiteMask,;
wProductType,;
wReserved
szCSDVersion = ""
PId = "(Unknown)"
lcProduct = ''
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
DO CASE
CASE dwMinorVersion = 0
PId = "2000 " && "Windows 2000 "
CASE dwMinorVersion = 1
PId = "XP " && "Windows XP "
IF BITAND(wSuiteMask, VER_SUITE_PERSONAL) <> 0
PId = PId + "Home "
ELSE
PId = PId + "Pro "
ENDIF
CASE dwMinorVersion = 2
PId = "2003 " && "Windows 2003 "
ENDCASE
CASE dwMajorVersion = 6
Declare INTEGER GetProductInfo in Kernel32 ;
LONG dwMajorVersion, ;
LONG dwMinorVersion, ;
LONG wServicePackMajor, ;
LONG wServicePackMinor, ;
LONG @pdwReturnedProductType
pdwReturnedProductType = INT(0)
lnResult = GetProductInfo( ;
dwMajorVersion, ;
dwMinorVersion, ;
wServicePackMajor, ;
wServicePackMinor, ;
@pdwReturnedProductType ;
)
IF lnResult = 1 && Good Result
lcProduct = getproduct(pdwReturnedProductType)
ENDIF
DO CASE
CASE dwMinorVersion = 0
IF BITAND(wProductType, VER_NT_SERVER) = VER_NT_SERVER
PId = "2008 " && "Windows 2008 Server "
ELSE
PId = "Vista " && "Windows Vista "
ENDIF
CASE dwMinorVersion = 1
PId = "Windows 7 " && "Windows 7 "
ENDCASE
ENDCASE
ENDCASE
lcReturn = PId ;
+ IIF(!EMPTY(lcProduct), lcProduct + ' ', '') ;
+ ALLTRIM(transform(dwMajorVersion,"@B 99999"));
+ "." + ALLTRIM(transform(dwMinorVersion,"@B 99999"));
+ "." + ALLTRIM(transform(dwBuildNumber,"@B 99999"));
+ " " + IIF(EMPTY(szCSDVersion),"(No SP)", szCSDVersion)
*c* + " (Build "+ ALLTRIM(transform(dwBuildNumber,"99999"));
*c* ;
*c* + ")"
*c* IF dwOSVersionInfoSize > 148
*c* lcReturn = lcReturn + CHR(13)+CHR(10)+TRANSFORM(wServicePackMajor) ;
*c* +" "+ TRANSFORM(wServicePackMinor) ;
*c* +" "+ TRANSFORM(wSuiteMask) ;
*c* +" "+ TRANSFORM(wProductType) ;
*c* +" "+ TRANSFORM(wReserved)
*c* ENDIF
ENDIF
RETURN lcReturn
**************************************************************************************
FUNCTION getproduct
LPARAMETERS znProductType
** pdwReturnedProductType
#DEFINE PRODUCT_BUSINESS 0x00000006 && Business Edition
#DEFINE PRODUCT_BUSINESS_N 0x00000010 && Business Edition
#DEFINE PRODUCT_CLUSTER_SERVER 0x00000012 && Cluster Server Edition
#DEFINE PRODUCT_DATACENTER_SERVER 0x00000008 && Server Datacenter Edition (full installation)
#DEFINE PRODUCT_DATACENTER_SERVER_CORE 0x0000000C && Server Datacenter Edition (core installation)
#DEFINE PRODUCT_DATACENTER_SERVER_CORE_V 0x00000027 && Server Datacenter Edition without Hyper-V (core installation)
#DEFINE PRODUCT_DATACENTER_SERVER_V 0x00000025 && Server Datacenter Edition without Hyper-V (full installation)
#DEFINE PRODUCT_ENTERPRISE 0x00000004 && Enterprise Edition
#DEFINE PRODUCT_ENTERPRISE_N 0x0000001B && Enterprise Edition
#DEFINE PRODUCT_ENTERPRISE_SERVER 0x0000000A && Server Enterprise Edition (full installation)
#DEFINE PRODUCT_ENTERPRISE_SERVER_CORE 0x0000000E && Server Enterprise Edition (core installation)
#DEFINE PRODUCT_ENTERPRISE_SERVER_CORE_V 0x00000029 && Server Enterprise Edition without Hyper-V (core installation)
#DEFINE PRODUCT_ENTERPRISE_SERVER_IA64 0x0000000F && Server Enterprise Edition for Itanium-based Systems
#DEFINE PRODUCT_ENTERPRISE_SERVER_V 0x00000026 && Server Enterprise Edition without Hyper-V (full installation)
#DEFINE PRODUCT_HOME_BASIC 0x00000002 && Home Basic Edition
#DEFINE PRODUCT_HOME_BASIC_N 0x00000005 && Home Basic Edition
#DEFINE PRODUCT_HOME_PREMIUM 0x00000003 && Home Premium Edition
#DEFINE PRODUCT_HOME_PREMIUM_N 0x0000001A && Home Premium Edition
#DEFINE PRODUCT_HOME_SERVER 0x00000013 && Home Server Edition
#DEFINE PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT 0x0000001E && Windows Essential Business Server Management Server
#DEFINE PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING 0x00000020 && Windows Essential Business Server Messaging Server
#DEFINE PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY 0x0000001F && Windows Essential Business Server Security Server
#DEFINE PRODUCT_SERVER_FOR_SMALLBUSINESS 0x00000018 && Server for Small Business Edition
#DEFINE PRODUCT_SMALLBUSINESS_SERVER 0x00000009 && Small Business Server
#DEFINE PRODUCT_SMALLBUSINESS_SERVER_PREMIUM 0x00000019 && Small Business Server Premium Edition
#DEFINE PRODUCT_STANDARD_SERVER 0x00000007 && Server Standard Edition (full installation)
#DEFINE PRODUCT_STANDARD_SERVER_CORE 0x0000000D && Server Standard Edition (core installation)
#DEFINE PRODUCT_STANDARD_SERVER_CORE_V 0x00000028 && Server Standard Edition without Hyper-V (core installation)
#DEFINE PRODUCT_STANDARD_SERVER_V 0x00000024 && Server Standard Edition without Hyper-V (full installation)
#DEFINE PRODUCT_STARTER 0x0000000B && Starter Edition
#DEFINE PRODUCT_STORAGE_ENTERPRISE_SERVER 0x00000017 && Storage Server Enterprise Edition
#DEFINE PRODUCT_STORAGE_EXPRESS_SERVER 0x00000014 && Storage Server Express Edition
#DEFINE PRODUCT_STORAGE_STANDARD_SERVER 0x00000015 && Storage Server Standard Edition
#DEFINE PRODUCT_STORAGE_WORKGROUP_SERVER 0x00000016 && Storage Server Workgroup Edition
#DEFINE PRODUCT_UNDEFINED 0x00000000 && An unknown product
#DEFINE PRODUCT_ULTIMATE 0x00000001 && Ultimate Edition
#DEFINE PRODUCT_ULTIMATE_N 0x0000001C && Ultimate Edition
#DEFINE PRODUCT_WEB_SERVER 0x00000011 && Web Server Edition (full installation)
#DEFINE PRODUCT_WEB_SERVER_CORE 0x0000001D && Web Server Edition (core installation)
LOCAL lcProductType
lcProductType = ''
DO CASE
** First the non-Servers
CASE znProductType = PRODUCT_BUSINESS OR znProductType = PRODUCT_BUSINESS_N
lcProductType = 'Business' && Edition'
CASE znProductType = PRODUCT_ENTERPRISE OR znProductType = PRODUCT_ENTERPRISE_N
lcProductType = 'Enterprise' && Edition'
CASE znProductType = PRODUCT_HOME_BASIC OR znProductType = PRODUCT_HOME_BASIC_N
lcProductType = 'Home Basic' && Edition'
CASE znProductType = PRODUCT_HOME_PREMIUM OR znProductType = PRODUCT_HOME_PREMIUM_N
lcProductType = 'Home Premium' && Edition'
CASE znProductType = PRODUCT_ULTIMATE OR znProductType = PRODUCT_ULTIMATE_N
lcProductType = 'Ultimate' && Edition'
CASE znProductType = PRODUCT_STARTER
lcProductType = 'Starter' && Edition'
CASE znProductType = PRODUCT_UNDEFINED
lcProductType = 'Unknown Product Type'
** Now the Servers
CASE znProductType = PRODUCT_CLUSTER_SERVER
lcProductType = 'Cluster Server Edition'
CASE znProductType = PRODUCT_DATACENTER_SERVER
lcProductType = 'Server Datacenter Edition (full installation)'
CASE znProductType = PRODUCT_DATACENTER_SERVER_CORE
lcProductType = 'Server Datacenter Edition (core installation)'
CASE znProductType = PRODUCT_DATACENTER_SERVER_CORE_V
lcProductType = 'Server Datacenter Edition without Hyper-V (core installation)'
CASE znProductType = PRODUCT_DATACENTER_SERVER_V
lcProductType = 'Server Datacenter Edition without Hyper-V (full installation)'
CASE znProductType = PRODUCT_ENTERPRISE_SERVER
lcProductType = 'Server Enterprise Edition (full installation)'
CASE znProductType = PRODUCT_ENTERPRISE_SERVER_CORE
lcProductType = 'Server Enterprise Edition (core installation)'
CASE znProductType = PRODUCT_ENTERPRISE_SERVER_CORE_V
lcProductType = 'Server Enterprise Edition without Hyper-V (core installation)'
CASE znProductType = PRODUCT_ENTERPRISE_SERVER_IA64
lcProductType = 'Server Enterprise Edition for Itanium-based Systems'
CASE znProductType = PRODUCT_ENTERPRISE_SERVER_V
lcProductType = 'Server Enterprise Edition without Hyper-V (full installation)'
CASE znProductType = PRODUCT_HOME_SERVER
lcProductType = 'Home Server Edition'
CASE znProductType = PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT
lcProductType = 'Windows Essential Business Server Management Server'
CASE znProductType = PRODUCT_MEDIUMBUSINESS_SERVER_MESSAGING
lcProductType = 'Windows Essential Business Server Messaging Server'
CASE znProductType = PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY
lcProductType = 'Windows Essential Business Server Security Server'
CASE znProductType = PRODUCT_SERVER_FOR_SMALLBUSINESS
lcProductType = 'Server for Small Business Edition'
CASE znProductType = PRODUCT_SMALLBUSINESS_SERVER
lcProductType = 'Small Business Server'
CASE znProductType = PRODUCT_SMALLBUSINESS_SERVER_PREMIUM
lcProductType = 'Small Business Server Premium Edition'
CASE znProductType = PRODUCT_STANDARD_SERVER
lcProductType = 'Server Standard Edition (full installation)'
CASE znProductType = PRODUCT_STANDARD_SERVER_CORE
lcProductType = 'Server Standard Edition (core installation)'
CASE znProductType = PRODUCT_STANDARD_SERVER_CORE_V
lcProductType = 'Server Standard Edition without Hyper-V (core installation)'
CASE znProductType = PRODUCT_STANDARD_SERVER_V
lcProductType = 'Server Standard Edition without Hyper-V (full installation)'
CASE znProductType = PRODUCT_STORAGE_ENTERPRISE_SERVER
lcProductType = 'Storage Server Enterprise Edition'
CASE znProductType = PRODUCT_STORAGE_EXPRESS_SERVER
lcProductType = 'Storage Server Express Edition'
CASE znProductType = PRODUCT_STORAGE_STANDARD_SERVER
lcProductType = 'Storage Server Standard Edition'
CASE znProductType = PRODUCT_STORAGE_WORKGROUP_SERVER
lcProductType = 'Storage Server Workgroup Edition'
CASE znProductType = PRODUCT_WEB_SERVER
lcProductType = 'Web Server Edition (full installation)'
CASE znProductType = PRODUCT_WEB_SERVER_CORE
lcProductType = 'Web Server Edition (core installation)'
OTHERWISE
lcProductType = ''
ENDCASE
RETURN lcProductType
ENDFUNC
*!* EOP: GETWINVER.PRG
*FUNCTION asc2BEint && remove * if not in a separate .PRG file
* Abstract...: Ascii String to BigEndian Integer (i.e. Most significant byte on right)
* (use asc2int() for LittleEndian)
* Doesn't return negative numbers, Unless asked for
* RETURN -1 if any error
* Changes....:
*FUNCTION asc2BEint
LPARAMETERS p_cString, p_nStart, p_nLength, p_nAllowNegative
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
IF PCOUNT() < 4 OR VARTYPE(p_nAllowNegative) <> "L"
p_nAllowNegative = .F.
ENDIF
LOCAL lnRet_val, llIsNegative, lcFixString, lnii, lcConvertString
lnRet_val = -1
llIsNegative = .F.
IF !BETWEEN(p_nLength, 1, 4)
RETURN lnRet_val
ENDIF
lcConvertString = SUBSTR(p_cString, p_nStart, p_nLength)
IF p_nAllowNegative
IF asc(SUBSTR(lcConvertString, (p_nLength-1), 1)) > 0x7F && It's Negative
lcFixString = lcConvertString
lcConvertString = ''
FOR lnii = 1 TO p_nLength
lcConvertString = lcConvertString + CHR(255-ASC(SUBSTR(lcFixString, lnii, 1))) && kludgy XOR
ENDFOR
llIsNegative = .T.
ENDIF
ENDIF
DO CASE
CASE p_nLength = 1
lnRet_val = asc(SUBSTR(lcConvertString, 1, 1))
CASE p_nLength = 2
lnRet_val = asc(SUBSTR(lcConvertString, 1, 1));
+ asc(SUBSTR(lcConvertString, 2, 1))*256
CASE p_nLength = 3
lnRet_val = asc(SUBSTR(lcConvertString, 1, 1));
+ asc(SUBSTR(lcConvertString, 2, 1))*256;
+ asc(SUBSTR(lcConvertString, 3, 1))*256^2
CASE p_nLength = 4
lnRet_val = asc(SUBSTR(lcConvertString, 1, 1));
+ asc(SUBSTR(lcConvertString, 2, 1))*256;
+ asc(SUBSTR(lcConvertString, 3, 1))*256^2;
+ asc(SUBSTR(lcConvertString, 4, 1))*256^3
OTHERWISE
lnRet_val = -1
ENDCASE
IF llIsNegative && Two's Complement Adj
lnRet_Val = -(lnRet_Val + 1)
ENDIF
RETURN INT(lnRet_val)
*!* EOP: ASC2BEINT.PRG |