www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/01/11:55:31

To: djgpp AT delorie DOT com
Subject: Re: Detecting win95: the hard way
References: <8D53104ECD0CD211AF4000A0C9D60AE35C4BCB AT probe-2 DOT acclaim-euro DOT net>
From: Michael Bukin <M DOT A DOT Bukin AT inp DOT nsk DOT su>
Date: 01 Mar 1999 22:37:43 +0600
In-Reply-To: Shawn Hargreaves's message of "Mon, 1 Mar 1999 12:57:57 -0000"
Message-ID: <20btidb1yg.fsf@Sky.inp.nsk.su>
Lines: 71
X-Mailer: Gnus v5.5/Emacs 19.34
Reply-To: djgpp AT delorie DOT com

Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk> writes:

> I need a way to detect when a djgpp program (Allegro) is being run
> under win95. At the moment I do this using the documented detection
> function, int 0x2F with ax=0x1600. The problem is that in the 
> properties for the win95 dosbox, there is an option to specifically
> stop this function from working, ie. to make win95 lie and pretend
> it isn't there. For some reason, it seems that significant numbers
> of people have this option enabled, with the result that Allegro
> mis-diagnoses the current environment, uses the wrong version of
> the timer module, and everything falls to pieces.

It seems that both "Get Application Title" and "Get Virtual Machine
Title" work with and without this flag set and don't work in MS-DOS
mode.  I can not say if there is a situation when they work in non
Windows environment or might fail in Windows environment.  I only
tested them in Windows-95 and MS-DOS 7.0.  Short example program

#include <go32.h>
#include <dpmi.h>
#include <stdio.h>
#include <stdlib.h>

int
main (void)
{
  int size;
  char *title;
  __dpmi_regs r;

  size = _go32_info_block.size_of_transfer_buffer;
  title = malloc (size);
  if (title == 0)
    {
      fprintf (stderr, "Not enough memory\n");
      exit (EXIT_FAILURE);
    }

  r.x.ax = 0x168E;
  r.x.es = (__tb >> 4) & 0xFFFF; /* Is this masking really needed?  */
  r.x.di = (__tb & 0x0F);
  r.x.cx = size - 1;
  r.x.dx = 2;
  __dpmi_int (0x2F, &r);
  if (r.x.ax != 1)
    {
      fprintf (stderr, "Failed to get application title!\n");
      exit (EXIT_FAILURE);
    }
  dosmemget (__tb, size, title);
  printf ("Application title: %s\n", title);

  r.x.ax = 0x168E;
  r.x.es = (__tb >> 4) & 0xFFFF;
  r.x.di = (__tb & 0x0F);
  r.x.cx = size - 1;
  r.x.dx = 3;
  __dpmi_int (0x2F, &r);
  if (r.x.ax != 1)
    {
      fprintf (stderr, "Failed to get virtual machine title!\n");
      exit (EXIT_FAILURE);
    }
  dosmemget (__tb, size, title);
  printf ("Virtual machine title: %s\n", title);

  return EXIT_SUCCESS;
}

-- 
Michael Bukin

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019