Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Detecting windows

Posted on 1999-01-10
8
Medium Priority
?
196 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: 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.

 
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 120 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
In this article, I’ll show how research, determination, and use of modern technology helped me solve a DNA mystery.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

721 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