home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9203 / ctrick / wintest.c < prev   
Encoding:
C/C++ Source or Header  |  1992-04-14  |  2.1 KB  |  103 lines

  1. /* ------------------------------------------------------ */
  2. /*                      WINTEST.C                         */
  3. /*            Test auf aktive Windows-Version             */
  4. /* Rückgabe : 0 -> Windows ist nicht aktiv                */
  5. /*            1 -> Windows läuft im REAL-Modus            */
  6. /*            2 -> Windows läuft im STANDARD-Modus        */
  7. /*            3 -> Windows läuft im ERWEITERTEN-386 Modus */
  8. /*        (c) 1992 Michael Winter & DMV-Verlag            */
  9. /* ------------------------------------------------------ */
  10.  
  11. #include <stdio.h>
  12. #include <bios.h>
  13. #include <stdlib.h>
  14.  
  15. /* --- Prototypen --------------------------------------- */
  16.  
  17. int main( void );
  18.  
  19. /* --- Hauptprogramm ------------------------------------ */
  20.  
  21. int main( void )
  22. {
  23.   unsigned int WIN386, WINR_OR_WIN286,
  24.                WIN386_OR_WIN286, ergi;
  25.   unsigned char ergc;
  26.  
  27.   printf("\nWinTest 1.0 - ");
  28.   printf("(c) 1992 Michael Winter & DMV-Verlag\n\n");
  29.  
  30.   _asm
  31.   {
  32.     mov ax, 0x4680;
  33.     int 0x2f;
  34.     mov ergc, ah;
  35.   }
  36.  
  37.   WINR_OR_WIN286 = (ergc == 0x00);
  38.  
  39.   _asm
  40.   {
  41.     mov ax, 0x1600;
  42.     int 0x2F;
  43.     mov ergc, al;
  44.   }
  45.  
  46.   WIN386 = ( (ergc == 0x01) || (ergc == 0xff) );
  47.  
  48.   if (WIN386)
  49.   {
  50.     printf("Windows ist im erweiterten 386-Modus aktiv\n");
  51.     exit(3);
  52.   }
  53.  
  54.   _asm
  55.   {
  56.     push es;
  57.     push ds;
  58.  
  59.     mov ax, 0x1605;
  60.     xor bx, 0x0000;
  61.     mov es, bx;
  62.     xor si, 0x0000;
  63.     mov ds, si;
  64.     xor cx, 0x0000;
  65.     mov dx, 0x0001;
  66.     int 0x2f;
  67.     mov ergi, cx;
  68.  
  69.     pop ds;
  70.     pop es;
  71.   }
  72.  
  73.   WIN386_OR_WIN286 = (ergi == 0xFFFF);
  74.  
  75.   if (ergi == 0x0000)
  76.     _asm
  77.     {
  78.       mov ax, 0x1606;
  79.       int 0x2f;
  80.     }
  81.  
  82.   if ( (!WIN386) && (!WIN386_OR_WIN286) &&
  83.        (!WINR_OR_WIN286) )
  84.   {
  85.     printf("Windows ist nicht aktiv\n");
  86.     exit(0);
  87.   }
  88.  
  89.   if (WIN386_OR_WIN286 && WINR_OR_WIN286)
  90.   {
  91.     printf("Windows ist im Standard-Modus aktiv\n");
  92.     exit(2);
  93.   }
  94.  
  95.   if (WINR_OR_WIN286)
  96.   {
  97.     printf("Windows läuft im Real-Modus\n");
  98.     exit(1);
  99.   }
  100. }
  101. /* ------------------------------------------------------ */
  102. /*                Ende von WINTEST.C                      */
  103.