Detecting OS/Windows 
Author Message
 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



Wed, 10 Mar 2004 14:46:50 GMT  
 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{*filter*}ts will be
returned to your postmaster, eh!



Thu, 11 Mar 2004 01:50:38 GMT  
 Detecting OS/Windows

Quote:

>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



Sat, 13 Mar 2004 05:09:36 GMT  
 Detecting OS/Windows

Quote:



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



Sat, 13 Mar 2004 05:17:28 GMT  
 Detecting OS/Windows

Quote:

>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.

--

   "I don't know. Do you think there are answers to everything
   here? Is that true in the place you come from?"



Sat, 13 Mar 2004 05:40:44 GMT  
 Detecting OS/Windows

Quote:



> > 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.



Sat, 13 Mar 2004 05:52:38 GMT  
 Detecting OS/Windows


Quote:

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



Sat, 13 Mar 2004 14:28:12 GMT  
 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



Sat, 13 Mar 2004 21:29:09 GMT  
 Detecting OS/Windows

Quote:





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


Sat, 13 Mar 2004 21:39:20 GMT  
 Detecting OS/Windows
On Tue, 25 Sep 2001 15:29:09 +0200, Markus Humm

Quote:

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



Mon, 15 Mar 2004 01:14:47 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Detecting OS/Windows

2. Detecting Windows from non-Windows program

3. WINDOWS ALTERNATIVE - OMNI OS

4. using windows(not the os)

5. WINDOWS ALTERNATIVE - OMNI OS

6. Delphi-Application for OS/2, Mac and Windows?

7. FA: Virtual Pascal for OS/2, RexxVIM for OS/2

8. detecting windows version from TP7?

9. Detecting Windows from a dos box...

10. Detect Windows 98

11. Detecting Windows

12. Detecting Windows DOS box

 

 
Powered by phpBB® Forum Software