4 * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 2002 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: win32os.c,v 1.5 2007/06/19 23:47:19 tbox Exp */
24 #include <isc/win32os.h>
26 static BOOL bInit
= FALSE
;
27 static OSVERSIONINFOEX osVer
;
30 initialize_action(void) {
36 * NOTE: VC++ 6.0 gets this function declaration wrong
37 * so we compensate by casting the argument
39 osVer
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
40 bSuccess
= GetVersionEx((OSVERSIONINFO
*) &osVer
);
43 * Versions of NT before NT4.0 SP6 did not return the
44 * extra info that the EX structure provides and returns
45 * a failure so we need to retry with the old structure.
48 osVer
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFO
);
49 bSuccess
= GetVersionEx((OSVERSIONINFO
*) &osVer
);
55 isc_win32os_majorversion(void) {
57 return ((unsigned int)osVer
.dwMajorVersion
);
61 isc_win32os_minorversion(void) {
63 return ((unsigned int)osVer
.dwMinorVersion
);
67 isc_win32os_servicepackmajor(void) {
69 return ((unsigned int)osVer
.wServicePackMajor
);
73 isc_win32os_servicepackminor(void) {
75 return ((unsigned int)osVer
.wServicePackMinor
);
79 isc_win32os_versioncheck(unsigned int major
, unsigned int minor
,
80 unsigned int spmajor
, unsigned int spminor
) {
84 if (major
< isc_win32os_majorversion())
86 if (major
> isc_win32os_majorversion())
88 if (minor
< isc_win32os_minorversion())
90 if (minor
> isc_win32os_minorversion())
92 if (spmajor
< isc_win32os_servicepackmajor())
94 if (spmajor
> isc_win32os_servicepackmajor())
96 if (spminor
< isc_win32os_servicepackminor())
98 if (spminor
> isc_win32os_servicepackminor())