home *** CD-ROM | disk | FTP | other *** search
- {$F+,R-,S-,V-}
-
- PROGRAM FINDWIN;
-
- {$M 1024,0,0}
-
- { Copyright (C) 1991 by: NativSoft Computing
- 1155 College Ave.
- Adrian, MI, 49221
- (517) 265-6080
- CIS 71160,1045
-
-
- A quick and dirty program to detect and report whether any version
- of Microsoft Windows (tm) is running.
-
- Based on information published in an article
- by Ben Myers of Spirit of Performance, Inc.
- (Dr. Dobb's Journal, #172, January, 1991, pg 116)
-
- ALTINTR was adapted from a public domain procedure
- found in INFOPLUS by ANDREW ROSSMAN. This procedure
- is necessary because TP only FAKES an INT!! The normal
- TP construct, INTR($2F,regs), therefore fails to detect
- Windows running in enhanced mode. With TP6's BASM the required
- code can be inserted directly into the body of the program.
-
- Compile with Turbo Pascal v5.5 (requires REALINT.OBJ) or
- Turbo Pascal v6 (requires conditional define "ver6")
-
- This program is released to the public domain and is provided
- "as is" without any warranty of any kind, either expressed or
- implied, including, but not limited to, the implied warranties
- or merchantability and fitness for a particular reason. The
- entire risk as to the quality and performance of the program
- is with the user.
-
- }
-
- uses dos,crt;
-
- {$IFNDEF ver6}
- {$L REALINT}
- PROCEDURE ALTINTR(a:byte;b:registers); external;
- {$ENDIF}
-
- var
- quiet : boolean;
- t : byte;
- x : word;
- {$IFNDEF ver6}
- regs : registers;
- {$ENDIF}
-
- BEGIN
- checkbreak := false;
- if paramstr(1) = '?' then
- begin
- clrscr;
- writeln('FINDWIN *** Copyright (C) 1991 by NativSoft Computing');
- writeln;
- writeln('This program returns:');
- writeln('Errorlevel = 0 No WIN version detected');
- writeln(' = 1 WIN 3.x enhanced');
- writeln(' = 2 WIN/386 or WIN 2.xx');
- writeln(' = 3 WIN 3.x real or standard');
- writeln;
- writeln('/Q (quiet) switch suppresses all messages normally written to');
- writeln('the screen, but still returns ERRORLEVELS for use in batch files');
- writeln;
- halt;
- end;
- quiet := ( (paramstr(1) = '/q') or (paramstr(1) = '/Q') );
-
- {$IFNDEF ver6}
- fillchar(regs,sizeof(regs),0);
- regs.ax := $1600;
- altintr($2F,regs);
- x := regs.al;
- {$ELSE}
- ASM
- MOV AX, 1600h
- INT 2Fh
- MOV x, AX
- END;
- x := lo(x);
- {$ENDIF}
-
-
- case x of
- $01,$FF : t := 2; {win/386, ver 2.xx running}
- $00,$80 : begin {Enhanced, WIN/386, or WIN ver 2.xx NOT RUNNING
- ... so, test for real or standard win 3.x }
-
- {$IFNDEF ver6}
- fillchar(regs,sizeof(regs),0);
- regs.ax := $4680;
- altintr($2F,regs);
- x := regs.ax;
- {$ELSE}
- ASM
- MOV AX, 4680h
- INT 2Fh
- MOV x, AX
- END;
- {$ENDIF}
-
-
- if x = 0 then t := 3 {real or standard win 3.x running}
- else t := 0; {apparently NO WIN is running}
- end;
- else t := 1; {enhanced win 3.x running}
- end; {case}
-
-
- if not quiet then
- begin
- clrscr;
- writeln('FINDWIN *** Copyright (C) 1991 by NativSoft Computing');
- writeln;
- case t of
- 0 : writeln('No version of Windows was detected');
- 1 : writeln('Windows 3 is running in enhanced mode');
- 2 : writeln('Windows/386 or Windows 2.x is running');
- 3 : writeln('Windows 3 is running in standard or real mode');
- end; {case}
- writeln;
- write('Press <ENTER> to continue...');
- readln;
- clrscr;
- end;
-
- halt(t);
-
- end.