Detecting Windows/Win95/NT 
Author Message
 Detecting Windows/Win95/NT

Hello!

Can anyone tell me how to code a simple test in TP7/BP7 if a DOS program
is running in "Command prompt only"-mode or in a DOS window with for
example Windows 95 loaded.

My program act differently with certain functions when running in a DOS
windows under W95 than with clean DOS 7.0, and I like to test which
environment the program is running from.

I would also appreciate if anyone had functions for reading/setting the
disk media ID/label for VFAT. I am familiar with these funtions for
regular FAT, but my programs now run poorly with these functions under
Windows 95/VFAT.

Thanx for any help/suggestions

Tommy.




Wed, 18 Jun 1902 08:00:00 GMT  
 Detecting Windows/Win95/NT

Quote:

> Can anyone tell me how to code a simple test in TP7/BP7 if a DOS program
> is running in "Command prompt only"-mode or in a DOS window with for
> example Windows 95 loaded.

> My program act differently with certain functions when running in a DOS
> windows under W95 than with clean DOS 7.0, and I like to test which
> environment the program is running from.

If the windows graphic user interface is currently active then the environment
variable 'Windir' will be present. If it's not present then you can assume that
windows is is not loaded and you are using 'Clean' DOS. This is also true in
the case of windows 3.xx.

--
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          ___!___            Geoff Keech

          o/   \o            Melbourne PC User Group, Australia.



Wed, 18 Jun 1902 08:00:00 GMT  
 Detecting Windows/Win95/NT

Quote:

> Hello!

> Can anyone tell me how to code a simple test in TP7/BP7 if a DOS program
> is running in "Command prompt only"-mode or in a DOS window with for
> example Windows 95 loaded.

> My program act differently with certain functions when running in a DOS
> windows under W95 than with clean DOS 7.0, and I like to test which
> environment the program is running from.

> I would also appreciate if anyone had functions for reading/setting the
> disk media ID/label for VFAT. I am familiar with these funtions for
> regular FAT, but my programs now run poorly with these functions under
> Windows 95/VFAT.

> Thanx for any help/suggestions

> Tommy.



You can detect the presence of Windows with the following call unless
(Win95) the "Prevent MS-DOS based programs from detecting
windows"-option is checked:

uses Dos;

function DetectWindows(var Version: Word): Boolean;
var
  Regs: Registers;
begin
  DetectWindows := False;
  Regs.AX := $1600;
  MsDos(Regs);
  if not (Regs.AL in [0, $80]) then
  begin
    DetectWindows := True;
    if not (Regs.AL in [1, $FF]) then
      Version := Regs.AX; { AL = major version >= 3, ah = minor version

Quote:
}

  end;
end;

var
  Version: Word;
begin
  Version := 0;
  if DetectWindows(Version) then
  begin
    Writeln('Windows active.');
    if Version <> 0 then
      Writeln('Running version ', Lo(Version), '.', Hi(Version));
  end else Writeln('Windows not active.');
end.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Detecting Windows NT

2. Detecting Windows from non-Windows program

3. Runtime error 200 when running under Windows 95 / Windows NT

4. Detect Win95 - Easy way?

5. Detecting window or fullscreen mode on W95 or NT

6. Delphi 2.0 only for Win95/Nt Apps

7. LoadLibrary works wunder NT but not win95

8. PARADOX, LAN, NT (WIN95):

9. Delphi 1/Interbase/Win95/NT Slowdown

10. Prevent the ShutDown of Win95 or NT

11. Runtime error under Win95 / Nt

12. Reading a QNX ZOS formatted file from win95/NT using Pascal

 

 
Powered by phpBB® Forum Software