home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / icat.zip / icatos2.zip / icatos2 / sample / SAMPLE.C next >
Text File  |  1996-01-17  |  2KB  |  67 lines

  1. /*
  2.  * This file communicates w/ SAMPLEDD.SYS to get at the BIOS data area that
  3.  * contains the number of columns for the screen.
  4.  *
  5.  * Written 3/92 by Jim Christensen.  Altered 4/92 by Dave Evans for ASDT32
  6.  * purposes.
  7.  */
  8.  
  9. #define INCL_DOS
  10. #include <os2.h>
  11.  
  12. #include <stdio.h>
  13. #include <conio.h>
  14.  
  15. #define SAMPLE_IOCTL_CATEGORY  0xE0
  16. #define SAMPLE_IOCTL_FUNC_INIT 0xF0
  17.  
  18. char devName[] = "$SAMPDD";
  19. short* columnCountPtr;
  20.  
  21. VOID int3( VOID );
  22.  
  23.   int
  24. main( )
  25. {
  26.   HFILE dev;
  27.   ULONG actionTaken, nBytes, devArgList;
  28.  
  29.   #define ESC 27
  30.   int promptChar = 0;
  31.  
  32.   /* Open the device driver */
  33.   if( DosOpen(devName, &dev, &actionTaken,
  34.                    0,                    /* new file size */
  35.                    0,                    /* new file attribute */
  36.                    OPEN_ACTION_OPEN_IF_EXISTS,
  37.                    OPEN_SHARE_DENYNONE + OPEN_FLAGS_NOINHERIT,
  38.                    NULL)                 /* ext.attrib buffer NULL */
  39.  
  40.       )
  41.       return( 1 );
  42.  
  43.   for( ; ; ) {
  44.     printf( "\nType any char to DevIOCTL sampledd.sys.  Type ESC to quit.\n" );
  45.     promptChar = getch( );
  46.     if( promptChar == ESC )
  47.       break;
  48.  
  49.     /* Get the address of the BIOS column count from the device */
  50.     nBytes = sizeof(devArgList);
  51.     if( DosDevIOCtl(dev, SAMPLE_IOCTL_CATEGORY, SAMPLE_IOCTL_FUNC_INIT,
  52.                    (PVOID) &devArgList, nBytes, &nBytes, NULL, 0L, NULL)
  53.       )
  54.       return( 1 );
  55.  
  56. /*  int3();  commented out 'cause we can't handle this yet! */
  57.  
  58.     /* Convert the returned 16:16 address to a 0:32 address */
  59.     columnCountPtr = (VOID*)(
  60.                      ((devArgList >> 19) << 16) | (devArgList & 0xFFFF) );
  61.     printf( "\nDereference of returned ptr = %d", *columnCountPtr );
  62.   }
  63.   printf( "\n" );
  64.  
  65.   return( 0 );
  66. }
  67.