Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi, I need to simply detect if my DOS program is running from pure DOS or under windows DOS-BOX. I use DJGPP/GCC. I tried something with INT2F/160A but it worked only with win3x/9x. I need to detect ALL windows versions. Thanks

I looked around on Google for something that might help but didn't have any luck.
Your question spawned one of my own though. Do you happen to have a link or something related to writing pure DOS programs? I've thought on and off the last year or so about learning to write a program that will run in DOS, not just a Windows console, preferable in C++ but C is good too.
I appreciate it, though am sorry I can't answer your question :)

Somebodedy adviced me a very simple way how to discover presence of windows NT. Every NT system needs to have set the environment variable SYSTEMROOT which points to windows root directory which is set in boot.ini. Its easy to get it by getenv() function. So I combined it together with int 2Fh code to this:
Word get_windows_version(void)
{
__dpmi_regs r;
if (getenv("SystemRoot")!=NULL) // identify windows NT environment
return(0x0500); // return version 5.00
r.x.ax=0x160A; // identify windows version and type
__dpmi_int(0x2F,&r); // int 2Fh (multiplexni preruseni)
if (r.x.ax!=0) // if call not supported
return(0); // return 0
else // else
return(r.x.bx); // return OS major,minor
}I'm playing with Pentium MTRR registers to enable Write-Combining mode to gain performance of VESA LFB under DOS. It's not needed to set it under windows because windows do itself. And more, RD/WR MSR is ring0 privilegen instruction so it would blow my program to hell so I needed to disable this part of code while running under windows.

Hi Ray,
As indicated, NT sets some telltale vars.
You can:
set NT=no
if %OS%!==Windows_NT! set NT=yesWith DOS based windows, not quite so simple. I don't have 98 running right now so I can't check, but I think the output of 'ver' is the same whether the GUI is running or not. So that won't help.
IIRR, a mem will reveal some useful stuff.
Try mem in pure DOS and from a DOS window.
With luck it may be as simple as win.com showing up in mem if it's loaded.
If so:
set OS=WIN
mem/c | find "WIN"
if errorlevel 1 set OS=DOS
M2

As I said, function 160Ah of INT 2Fh works well under Win 3.x and 9x so I keep it as is. Its true that win9x doesnt's set any special variable while GUI is running so you can't differ DOS mode (booter after hold down F8) and GUI mode by some variable.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |