Solved

Detecting windows

Posted on 1999-01-10
8
163 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

930 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

10 Experts available now in Live!

Get 1:1 Help Now