Link to home
Start Free TrialLog in
Avatar of jack_p50
jack_p50

asked on

Detecting windows

How dos program can detect if was runned from windows (if windows are running)?
Avatar of scrapdog
scrapdog
Flag of United States of America image

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;

I just tested it, and yes, the above code will detect Windows 95/98.
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.
Avatar of jack_p50
jack_p50

ASKER

I'm satisfyed. Please post lightly modified function, that returns version as answer.
ASKER CERTIFIED SOLUTION
Avatar of scrapdog
scrapdog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, winver returns 4.0 in win95/98.
4.0 is Windows 95, 4.10 is Windows 98.
you've 98? I'm OSR2