Board index » delphi » Detecting OS/Windows

Detecting OS/Windows

Hello!

I'm looking for a reliable way to detect the following OS:

- MS DOS 7.x
- MS DOS 8.0 (from ME with ripped off GUI)
- Windows 95 (GUI)
- Windows 98/98SE
- Windows ME
- Windows NT
- Windows 2000
- Windows XP

I'm writing some DOS app. There I want to know, whether I run under pure
DOS or under Windooze. It would be fine if this detection couldn't be
fooled by the Windows option not to show Windows presence (disabled
detection of windows).

Thanks in advance.

Markus

 

Re:Detecting OS/Windows


On Sat, 22 Sep 2001 08:46:50 +0200, Markus Humm sez:

Quote
>I'm writing some DOS app. There I want to know, whether I run under pure
>DOS or under Windooze. It would be fine if this detection couldn't be
>fooled by the Windows option not to show Windows presence (disabled
>detection of windows).

Well, I played around with DOS interrupt functions 30h and 33h, but
Windows lies - it says version 7.10 for both 95 and 98, and 5.0 for
NT.  There aren't any consistent environment variables to check,
either.

I'm sure one of the OS gurus will have a more elegant solution, but
here's a kludge if you can't find anything else:  Shell to DOS and run
the VER command, redirecting it to a file (e.g., "VER > VER.TMP") and
then read in the contents of that file.  Messy, but accurate and it
will work for any DOS/Winduhs version.

Of course, that won't tell you if they restarted in DOS-only mode
under 9x so you won't know if the GUI is active.

Peter B. Steiger
Cheyenne, WY
----
If you reply by email, send it to pbs at com dot
canada (or vice-versa).  All adverti{*word*224}ts will be
returned to your postmaster, eh!

Re:Detecting OS/Windows


On Sat, 22 Sep 2001 17:50:38 GMT, see....@for.email.address (Peter B.

Quote
Steiger) wrote:
>On Sat, 22 Sep 2001 08:46:50 +0200, Markus Humm sez:
>>I'm writing some DOS app. There I want to know, whether I run under pure
>>DOS or under Windooze. It would be fine if this detection couldn't be
>>fooled by the Windows option not to show Windows presence (disabled
>>detection of windows).

>Well, I played around with DOS interrupt functions 30h and 33h, but
>Windows lies - it says version 7.10 for both 95 and 98, and 5.0 for
>NT.  There aren't any consistent environment variables to check,

Well, not quite correct. As these are "DOS" functions, they return
what is to be expected, the version of the underlying or emulated (NT)
DOS Version.
This is 7.0 for Win95 and Win95A (FAT16 supprt only) and 7.1 for all
FAT32 enabled version of Win95B, Win95C, Win98 and Win98SE.
For all Windows NT Versions and W2K, it returns 5.50, which makes it
distiguishable from a "real" DOS 5.0x
Quote
>either.

>I'm sure one of the OS gurus will have a more elegant solution, but
>here's a kludge if you can't find anything else:  Shell to DOS and run
>the VER command, redirecting it to a file (e.g., "VER > VER.TMP") and
>then read in the contents of that file.  Messy, but accurate and it
>will work for any DOS/Winduhs version.

There are those INT 2F (Multiplexor) calls, but these work reliably
only for Windows <=3.1x, as for Windows 95 and newer, you can disable
the the detection through this call and i have not found a reliable
method to cirumvent this either....

Ralf

Re:Detecting OS/Windows


Quote
In article <jo7vqtk83gvdk7khbfgb1gh6d3c170e...@4ax.com>, Ralf Quint wrote:
> On Sat, 22 Sep 2001 17:50:38 GMT, see....@for.email.address (Peter B.
> Steiger) wrote:

> There are those INT 2F (Multiplexor) calls, but these work reliably
> only for Windows <=3.1x, as for Windows 95 and newer, you can disable
> the the detection through this call and i have not found a reliable
> method to cirumvent this either....

Another way is to try to verify if certain files (registry, swap) are
locked. This is only theory though. I don't know if you can mute the win32
critical handler from dos.

And even then you'd have to face non standard locations (or try to peek in
the registry file)

Re:Detecting OS/Windows


Quote
Ralf Quint <ralf_quint@hot_mail.com> wrote:
>There are those INT 2F (Multiplexor) calls, but these work reliably
>only for Windows <=3.1x, as for Windows 95 and newer, you can disable
>the the detection through this call and i have not found a reliable
>method to cirumvent this either....

Since this is for a DOS application, use the call to detect WinOldAp,
INT 2Fh .AX=1700h.  The "Prevent MS-DOS-based programs from
detecting Windows" option has no effect on this call.

--
Charles Dye   <ras...@highfiber.com>
   "I don't know. Do you think there are answers to everything
   here? Is that true in the place you come from?"

Re:Detecting OS/Windows


Marco van de Voort <mar...@toad.stack.nl> wrote:

Quote
>  In article <jo7vqtk83gvdk7khbfgb1gh6d3c170e...@4ax.com>, Ralf Quint wrote:
> > On Sat, 22 Sep 2001 17:50:38 GMT, see....@for.email.address (Peter B.
> > Steiger) wrote:

> > There are those INT 2F (Multiplexor) calls, but these work reliably
> > only for Windows <=3.1x, as for Windows 95 and newer, you can disable
> > the the detection through this call and i have not found a reliable
> > method to cirumvent this either....

>  Another way is to try to verify if certain files (registry, swap) are
>  locked. This is only theory though. I don't know if you can mute the win32
>  critical handler from dos.

I do not know, but won't this (untested) work in most cases?

{$IFOPT I+}
{$DEFINE IO_CHECK}
{$ENDIF}
{$I-}
function CheckWin: boolean;
var swap: file;
    drive: char;
begin
        CheckWin := false;
        for drive := 'c' to 'z' do
        begin
                assign (swap, drive + ':\win386.swp');
                reset (swap, 1);
                if InOutRes = 0 then
                begin
                        close (swap);
                        exit;
                end;
                close (swap);
                if IOResult = 5 then       {Won't it be access denied?}
                begin
                        CheckWin := true;
                        exit;
                end;
        end;
end;
{$IFDEF IO_CHECK}
{$I+}
{$ENDIF}

--
Why slrn?
Gnus is much too easy...

to pronounce.

Re:Detecting OS/Windows


On Mon, 24 Sep 2001 21:40:44 GMT, ras...@highfiber.com (Charles Dye)
wrote:

Quote
>Ralf Quint <ralf_quint@hot_mail.com> wrote:

>>There are those INT 2F (Multiplexor) calls, but these work reliably
>>only for Windows <=3.1x, as for Windows 95 and newer, you can disable
>>the the detection through this call and i have not found a reliable
>>method to cirumvent this either....

>Since this is for a DOS application, use the call to detect WinOldAp,
>INT 2Fh .AX=1700h.  The "Prevent MS-DOS-based programs from
>detecting Windows" option has no effect on this call.

Windows NT/2K at least don't seem to give anything useful back here
either, i have tried proabably all of the more or less obvious things.
It seems that the whole INT 2F interface is practically outdated on
the newer Windows versions, as M$ might think it's not necessary to
provide such way of DOS support anymore.

The best option that i came across so far, but needs some more
investigation, is more related to memory management calls, there i see
some chances actually being able to distinguish the newer Windows
versions, even if detection per INT 2F is disabled....

Ralf

Re:Detecting OS/Windows


Many thanks to all!!!!

Yesterday I found some C source who seems to be able to reliable detect
the Windows Version and the DOS Version at ONE time (means if windows
95b is detected Win95b AND DOS 7.1 are reported). Now I only have to
translate the C code to Pascal.
If someone wants to do this (as I only know Java...but I'll try to
translate it anyway), feel free. if anyone needs the code, just mail me!

Okay, XP detection isn't in it yet, but Win2k

Greetings

Markus

Re:Detecting OS/Windows


Quote
In article <slrn9qvap6.dtd.adsgoh...@www42.durchnull.de>, Rudolf Polzer wrote:
> Marco van de Voort <mar...@toad.stack.nl> wrote:
>>  In article <jo7vqtk83gvdk7khbfgb1gh6d3c170e...@4ax.com>, Ralf Quint wrote:
>> > On Sat, 22 Sep 2001 17:50:38 GMT, see....@for.email.address (Peter B.
>> > Steiger) wrote:

>> > There are those INT 2F (Multiplexor) calls, but these work reliably
>> > only for Windows <=3.1x, as for Windows 95 and newer, you can disable
>> > the the detection through this call and i have not found a reliable
>> > method to cirumvent this either....

>>  Another way is to try to verify if certain files (registry, swap) are
>>  locked. This is only theory though. I don't know if you can mute the win32
>>  critical handler from dos.

> I do not know, but won't this (untested) work in most cases?

Afaik no, but I didn't test. Problem is that the win32 critical handler says
it is being molested, while the iocheck mask only ignoring return codes from
the dos subsystem. (afaik {$I-} don't even help against the critical handler
from dos in many cases)

Re:Detecting OS/Windows


On Tue, 25 Sep 2001 15:29:09 +0200, Markus Humm

Quote
<markus.h...@freenet.de> wrote:
>Many thanks to all!!!!

>Yesterday I found some C source who seems to be able to reliable detect
>the Windows Version and the DOS Version at ONE time (means if windows
>95b is detected Win95b AND DOS 7.1 are reported). Now I only have to
>translate the C code to Pascal.
>If someone wants to do this (as I only know Java...but I'll try to
>translate it anyway), feel free. if anyone needs the code, just mail me!

I'd be interested. Can you send it off to me?

Regards,
Jim Wilson
(Cheap spam protection in place: remove the 'SpamThis'
from my email ID to reply to me personally)

Other Threads