Solved

Detecting windows

Posted on 1999-01-10
8
159 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
 
LVL 4

Author Comment

by:jack_p50
ID: 1216882
I'm satisfyed. Please post lightly modified function, that returns version as answer.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

A Short Story about the Best File Recovery Software – Acronis True Image 2017
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now