Mail Archives: djgpp/2000/03/21/03:06:26
Hello.
Damian Yerrick wrote:
> Isn't there a "Get version of Windows" interrupt call? Wouldn't it
> return 4.x for NT 4.x and 5.x for 2000? Allegro seems to be able to
> get the version number of the running GUI quite nicely. Or is it
> implemented on the 3.1/9x fork only?
Well, here's the code (for DJGPP) I have in libsocket:
int __get_windows_version (void)
{
union REGS r;
int win_version;
/* Get the windows version with INT 0x2F sub-function 0x160A,
* Windows 3.1+ installation check. This version check isn't
* amazing, but is probably enough because if the version isn't
* right then the VxDs will fail to load anyway. */
bzero ((void *) &r, sizeof (r));
r.x.ax = 0x160A;
int86(0x2F, &r, &r);
if (r.h.bh == 3) {
win_version = WIN_311;
} else if (r.h.bh > 3) {
/* TODO: Distinguish between '95, '98? */
/* Windows '95 or '98 */
win_version = WIN_95;
} else {
win_version = WIN_NONE;
}
/* If win_version is WIN_NONE, then we need to use the DOS version
* to determine if this is Windows NT. Thanks to Allegro (Shawn
* Hargreaves et al) for this method. It's also in Ralph Brown's
* Interrupt list,
* INT 0x21, AX = 0x3306. */
if (win_version == WIN_NONE) {
if (_get_dos_version(1) == 0x532) {
win_version = WIN_NT;
}
}
return(win_version);
}
WIN_* are in an enum. BTW I haven't tried this under Windows NT, but I
think it'll work. I don't know what Win2k will return for
_get_dos_version().
HTH, bye,
--
Richard Dawe
richdawe AT bigfoot DOT com ICQ 47595498 http://www.bigfoot.com/~richdawe/
- Raw text -