Solved

Detecting windows

Posted on 1999-01-10
8
191 Views
Last Modified: 2010-04-16
How dos program can detect if was runned from windows (if windows are running)?
0
Comment
Question by:jack_p50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 5

Expert Comment

by:scrapdog
ID: 1216879
This will detect if Windows 3.1 is running...I'm not sure if it detects Windows 95 though...


Type
  Win3ModeType = (NoWin, RealStd, Enhanced);

Function CheckForWin3 : Win3ModeType;  Assembler;
Asm
  mov    ax,1600h
  int    2Fh
  cmp    al,1
  jbe    @@CheckRealStd
  cmp    al,80h
  jae    @@CheckRealStd
  mov    al,2
  jmp    @@ExitPoint
@@CheckRealStd:
  mov    ax,4680h
  int    2Fh
  or     ax,ax
  jnz    @@notWin
  mov    al,1
  jmp    @@ExitPoint
@@notWin:
  xor    al,al
@@ExitPoint:
end;

0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1216880
I just tested it, and yes, the above code will detect Windows 95/98.
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1216881
If you want to determine the exact version of Windows, you can check the contents of the accumulator after the first call to interrupt $2f.  AL will contain the "integer" part of the version, and AH will contain the "decimal part".  Example AL=3, AH=11 means Windows 3.11.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 4

Author Comment

by:jack_p50
ID: 1216882
I'm satisfyed. Please post lightly modified function, that returns version as answer.
0
 
LVL 5

Accepted Solution

by:
scrapdog earned 30 total points
ID: 1216883
Here is a complete program from SWAG which does exactly what you request...extract the functions you need, of course.


Program Win3XInf;      { Simple Detection routines For Windows 3.X    }
                       { Last Updated March 3/93, Greg Estabrooks     }
Uses
  Crt,
  Dos;

Var
  Regs : Registers;    { to hold register info }

Function Win3X : Boolean;
{ Routine to determine if Windows is currently running }
begin
  Regs.AX := $4680;    { Win 3.x Standard check }
  Intr($2F, Regs);     { Call Int 2F }
  if Regs.AX <> 0 then { if AX = 0 Win in Real mode }
  begin                { else check For enhanced mode }
    Regs.AX := $1600;  { Win 3.x Enhanced check }
    Intr($2F, Regs);   { Call Int 2F }
    if Regs.AL in [$00,$80,$01,$FF] then { Check returned value }
      Win3X := False   { Nope not installed }
    else
      Win3X := True;   { Ya it is }
  end
  else
    Win3X := True;     { Return True }
end;


Function WinVer :Word;
{  Returns a Word containing the version of Win Running }
{  Should only be used after checking For Win installed }
{  Or value returned will be meaningless                }
begin
  Regs.AX := $1600;    {  Enhanced mode check }
  Intr($2F, Regs);     {  Call Int 2F         }
  WinVer := Regs.AX;   {  Return proper value }
end;


begin
  ClrScr;
  if Win3X then
  begin
    Writeln('Windows is Running! ');    { Display version }
    Writeln('Version Running is : ', Lo(WinVer), '.', Hi(WinVer));
  end
  else
    Writeln('Windows is not Running!');
end.

0
 
LVL 4

Author Comment

by:jack_p50
ID: 1216884
OK, winver returns 4.0 in win95/98.
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 1216885
4.0 is Windows 95, 4.10 is Windows 98.
0
 
LVL 4

Author Comment

by:jack_p50
ID: 1216886
you've 98? I'm OSR2
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
The recent Petya-like ransomware attack served a big blow to hundreds of banks, corporations and government offices The Acronis blog takes a closer look at this damaging worm to see what’s behind it – and offers up tips on how you can safeguard your…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question