Microsoft KB Archive/65103

= OS/2 Basic Program to Get Machine Configuration; DosDevConfig =

Article ID: 65103

Article Last Modified on 12/12/2003

-

APPLIES TO


 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q65103



SUMMARY
A protected mode Basic program can call the OS/2 API function DosDevConfig to find out machine-configuration information, such as how many printers are attached, how many serial ports and floppy disk drives are available, whether or not a math coprocessor is present, and the type of primary display adapter (monochrome or color). Below is a sample program demonstrating this.

This information applies to Microsoft Basic Compiler versions 6.00 and 6.00b for MS OS/2 and to Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS OS/2.



MORE INFORMATION
DosDevConfig takes the following parameters:   Parameter   Description -  ---

PTR BYTE   Receives machine information

WORD       Type of information needed 0 = Number of printers attached 1 = Number of serial ports available 2 = Number of floppy disk drives available 3 = Check math coprocessor (returns 1 = present, 0 = not) 4 = PC Submodel type 5 = PC model type 6 = Primary display adapter type (returns 0 = monochrome,                  1 = color)

WORD       Reserved by OS/2, must be set to 0 Basic 6.00 and 6.00b and Basic PDS 7.00 and 7.10 can directly call OS/2 API functions by linking with the DOSCALLS.LIB (for 6.00 and 6.00b) or OS2.LIB (for 7.00 and 7.10) libraries. Note that a BYTE in Basic has a type of STRING * 1, and a WORD has a type of INTEGER. Also, data items preceded by PTR can be passed using the SEG keyword in the DECLARE statement; otherwise, BYVAL is used.

For more information on DosDevConfig, see Pages 509-510 of &quot;Advanced OS/2 Programming&quot; by Ray Duncan (Microsoft Press, 1989).

The following sample program (MACHINFO.BAS) displays configuration information about the machin, namely, how many printers are attached, how many serial ports and floppy disk drives are available, whether or not a math coprocessor is present, and the type of primary display adapter (monochrome or color). Note that a printer does not have to be online to be &quot;attached.&quot;

To compile the program, enter the following at the OS/2 command prompt:

bc machinfo;

The LINK command line for Basic 6.00 and 6.00b is as follows:   link /nop machinfo,,,doscalls; The LINK command line for Basic PDS 7.00 and 7.10 is as follows:   link /nop machinfo,,,os2;

MACHINFO.BAS
DEFINT A-Z

TYPE InfoType Info AS STRING * 1 END TYPE

DECLARE FUNCTION DosDevConfig% (SEG InfoVar AS InfoType,_                               BYVAL InfoNeeded%, BYVAL Reserved%)

DIM InfoVar AS InfoType  'Will receive configuration information.

'Get number of printers attached. ErrorCode% = DosDevConfig% (InfoVar, 0, 0) PRINT &quot;There are&quot; CVI(InfoVar.Info + CHR$(0)) &quot; printers attached.&quot;

'Get number of serial ports available. ErrorCode% = DosDevConfig% (InfoVar, 1, 0) PRINT CVI(InfoVar.Info + CHR$(0)) &quot; serial ports are available.&quot;

'Get number of floppy disk drives available. ErrorCode% = DosDevConfig% (InfoVar, 2, 0) PRINT CVI(InfoVar.Info + CHR$(0)) &quot; disk drives are available.&quot;

'Check if math coprocessor is available. ErrorCode% = DosDevConfig% (InfoVar, 3, 0) IF InfoVar.Info = CHR$(1) THEN PRINT &quot;A math coprocessor is present.&quot; ELSE PRINT &quot;A math coprocessor is not present.&quot; END IF

'Get the type of primary display adapter (color or mono). ErrorCode% = DosDevConfig% (InfoVar, 6, 0) IF InfoVar.Info = CHR$(1) THEN PRINT &quot;The primary display adapter is color.&quot; ELSE PRINT &quot;The primary display adapter is monochrome.&quot; END IF

END

Additional query words: BasicCom

Keywords: KB65103

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.