Solved

Detecting windows

Posted on 1999-01-10
8
176 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
  • 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Delphi TDBX too many connection problem 2 1,165
default value in Delphi component 2 519
FMXGrid getting check box state 5 522
Lazarus (freePascal) DB Project Assistance 14 482
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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