Microsoft KB Archive/66772

OS/2 COBOL Can Determine Video Adapter, Display, Memory

PSS ID Number: Q66772 Article last modified on 11-13-1990

4.00 OS/2

Summary: A protected mode COBOL program can determine the type of video adapter installed, how much memory is available on it, and the type of display device attached by calling the OS/2 API function VioGetConfig. Below is an program example demonstrating this. This information applies to Microsoft COBOL Professional Development System (PDS) version 4.00 for MS OS/2.

More Information: COBOL programs can call OS/2 API functions directly by prefixing the function names with a double-underscore (&quot;__&quot;). The OS/2 API calling convention can be declared in the SPECIAL-NAMES paragraph. VioGetConfig takes three parameters: a 2-byte value of 0, the far address to a buffer that receives the video adapter, display, and memory information, and a 2-byte video handle (0=default). Below is a code example (VIDINFO.CBL) that calls VioGetConfig and reports the type of video adapter being used, the type of display attached, and the amount of video memory available. To compile and link the program under COBOL PDS 4.00, use PWB.EXE or execute the following commands from the OS/2 prompt: COBOL VIDINFO; LINK /NOD VIDINFO,,,LCOBOL OS2;

Code Example
* Declare OS/2 API calling convention. SPECIAL-NAMES. CALL-CONVENTION 3 IS OS2API. DATA DIVISION. WORKING-STORAGE SECTION. * Receives information about adapter, display, and video memory. 01 Buffer. 05 BufferLength  PIC 9(4) COMP-5 VALUE 10. 05 AdapterType   PIC 9(4) COMP-5. 05 DisplayType   PIC 9(4) COMP-5. 05 VideoMemory   PIC 9(8) COMP-5. PROCEDURE DIVISION. *   Make the API call. CALL OS2API &quot;__VioGetConfig&quot; USING BY VALUE    0 SIZE 2, BY REFERENCE Buffer, BY VALUE    0 SIZE 2. *   Report the type of video adapter installed. EVALUATE AdapterType WHEN 0          DISPLAY &quot;MDA&quot; WHEN 1          DISPLAY &quot;CGA&quot; WHEN 2          DISPLAY &quot;EGA&quot; WHEN 3          DISPLAY &quot;VGA, PS/2&quot; WHEN 4 THROUGH 6 DISPLAY &quot;UNKNOWN&quot; WHEN 7          DISPLAY &quot;8514/A&quot; END-EVALUATE. *   Report the type of display device attached. EVALUATE DisplayType WHEN 0          DISPLAY &quot;Monochrome&quot; WHEN 1          DISPLAY &quot;RGB&quot; WHEN 2          DISPLAY &quot;Enhanced&quot; WHEN 3          DISPLAY &quot;8503 Analog Monochrome&quot; WHEN 4          DISPLAY &quot;8512 or 8513 Analog Color&quot; WHEN 5 THROUGH 8 DISPLAY &quot;UNKNOWN&quot; WHEN 9          DISPLAY &quot;8514 Analog Color&quot; END-EVALUATE. *   Report the amount of video memory available, then stop. DISPLAY VideoMemory &quot;K bytes on board&quot;. STOP RUN. Copyright Microsoft Corporation 1990.