Mail Archives: djgpp/1996/09/29/12:20:40
Message-ID: | <01BBAE2A.8D145500@slip00-17.btx.dtag.de>
|
From: | Daniel Jungbluth <danju AT t-online DOT de>
|
To: | "'DJGPP Mailing List'" <djgpp AT delorie DOT com>
|
Subject: | Re: Simple Questions
|
Date: | Sun, 29 Sep 1996 17:20:34 +-100
|
MIME-Version: | 1.0
|
Tim Gunn wrote:
>Secondly how do i test if a program is running under windows?
>and how do i find out the version of the DOS/Windows version.
The following code demonstrates, how to find the Windows version (feel =
free to use it in your program but let me know about your program :)
#include <dos.h>
#include <stdio.h>
#include <dpmi.h>
#define NO_WIN 0x00
#define WIN_386_X 0x01
#define WIN_REAL 0x81
#define WIN_STANDARD 0x82
#define WIN_ENHANCED 0x83
int windows_version( int *major, int *minor )
{
__dpmi_regs regs;
*major =3D 0;
*minor =3D 0;
/*-- Identifiziere Windows x.y im Erweiterten-Modus -----------------*/
regs.x.ax =3D 0x1600; /* Installationscheck Windows =
*/
__dpmi_int( 0x2F, ®s );
switch ( regs.h.al )
{
case 0x01:
case 0xFF: *major =3D 2;*minor =3D 0;return WIN_386_X; /* =
Windows /386 Version 2.x */
case 0x00:
case 0x80: regs.x.ax =3D 0x4680; /* Real- u. =
Standardmodus */
__dpmi_int( 0x2F, ®s );
if ( regs.h.al =3D=3D 0x80 ) return NO_WIN; /* =
Windows l"uft nicht */
else
{
/*-- Windows im Real- oder Standardmodus --------------*/
regs.x.ax =3D 0x1605; /* Initialisierung simulieren */
regs.x.bx =3D regs.x.si =3D regs.x.cx =3D regs.x.es =3D regs.x.ds =
=3D 0x0000;
regs.x.dx =3D 0x0001;
__dpmi_int( 0x2F, ®s );
if ( regs.x.cx =3D=3D 0x0000 )
{
/*-- Windows im Real-Modus ---------------------------*/
regs.x.ax =3D 0x1606;
__dpmi_int( 0x2F, ®s );
return WIN_REAL;
}
else return WIN_STANDARD;
}
/*-- Windows im Erweiterten-Modus, ax enth"lt Versionsnummer =
-------*/
default: *major =3D regs.h.al; /* Windows Version ausgeben */
*minor =3D regs.h.ah;
return WIN_ENHANCED; /* Windows im Erweiterten-Modus */
}
}
int main( void )
{
int win_mode,hver,lver;
win_mode =3D windows_version( &hver, &lver );
switch ( win_mode )
{
case NO_WIN: printf( "Windows not active\n" );break;
case WIN_REAL: printf( "Windows/real-mode detected\n" );break;
case WIN_STANDARD: printf( "Windows/standard-mode detected\n" =
);break;
case WIN_386_X: printf( "Windows/386 V 2.x detected" );break;
case WIN_ENHANCED: printf( "Windows/enhanced-mode v%d.%d =
detected\n",hver, lver );break;
}
return( win_mode );
}
- Raw text -