Computing.Net > Forums > Programming > How to detect Window from my DOS pr

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to detect Window from my DOS pr

Reply to Message Icon

Name: RayeR
Date: March 19, 2005 at 10:40:19 Pacific
OS: DOS/WIN
CPU/Ram: P6/512M
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Dr. Nick
Date: March 19, 2005 at 14:44:29 Pacific
Reply:

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 :)


0

Response Number 2
Name: RayeR
Date: March 19, 2005 at 19:48:44 Pacific
Reply:

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.


0

Response Number 3
Name: Mechanix2Go
Date: March 19, 2005 at 20:47:30 Pacific
Reply:

Hi Ray,

As indicated, NT sets some telltale vars.

You can:

set NT=no
if %OS%!==Windows_NT! set NT=yes

With 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


0

Response Number 4
Name: RayeR
Date: March 20, 2005 at 04:42:15 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: How to detect Window from my DOS pr

How to detect Vista using VER www.computing.net/answers/programming/how-to-detect-vista-using-ver/17396.html

how to manipulated windows command www.computing.net/answers/programming/how-to-manipulated-windows-command/14736.html

How to return value from batch file www.computing.net/answers/programming/how-to-return-value-from-batch-file/17016.html