Jump to content

DosDevConfig: Difference between revisions

From EDM2
Created page with " ==Syntax== Gets information about attached devices. #define INCL_DOSPROCESS #include <os2.h> PVOID pdevinfo; /* Address of the area where the information is retur..."
 
Ak120 (talk | contribs)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Gets information about attached devices.


==Syntax==
==Syntax==
Gets information about attached devices.
  DosDevConfig(pdevinfo, item)
 
  #define INCL_DOSPROCESS
#include <os2.h>
PVOID    pdevinfo;  /*  Address of the area where the information is returned. */
ULONG    item;      /*  Device information to be returned. */
APIRET    ulrc;      /*  Return Code. */
ulrc = DosDevConfig(pdevinfo, item);


==Parameters==
==Parameters==
'''pdevinfo (PVOID) - output'''
;pdevinfo (PVOID) - output: Address of the area where the information is returned.
 
:All returned device information is BYTE-sized, so this should be the address of a BYTE variable.
Address of the area where the information is returned.
;item (ULONG) - input: Device information to be returned.
 
:This parameter has one of the possible values:
All returned device information is BYTE-sized, so this should be the address of a BYTE variable.  
::0 DEVINFO_PRINTER: Number of parallel or printer ports.
 
::1 DEVINFO_RS232: Number of RS232 ports.
'''item (ULONG) - input'''
::2 DEVINFO_FLOPPY: Number of diskette drives.
 
::3 DEVINFO_COPROCESSOR: Presence of math coprocessor hardware:
Device information to be returned.
:::0 No coprocessor hardware
 
:::1 Coprocessor hardware installed  
This parameter has one of the possible values:
::4 DEVINFO_SUBMODEL: PC Submodel Type. The returned information is the system submodel byte.
 
::5 DEVINFO_MODEL: PC Model Type. The returned information is the system model byte.
* DEVINFO_PRINTER Number of parallel or printer ports.
::6 DEVINFO_ADAPTER: Type of primary display adapter:
 
:::0 Monochrome or printer adapter
* DEVINFO_RS232
:::1 Other
Number of RS232 ports.
 
* DEVINFO_FLOPPY
Number of diskette drives.
 
* DEVINFO_COPROCESSOR
Presence of math coprocessor hardware:
 
** No coprocessor hardware
** Coprocessor hardware installed  
 
* DEVINFO_SUBMODEL
PC Submodel Type. The returned information is the system submodel byte. 5
 
* DEVINFO_MODEL
PC Model Type. The returned information is the system model byte. 6
 
* DEVINFO_ADAPTER
Type of primary display adapter:
 
** Monochrome or printer adapter
** Other
 
'''ulrc (APIRET) - returns'''
 
Return Code.
 
DosDevConfig returns one of the following values:
 
* NO_ERROR 87 - ERROR_INVALID_PARAMETER
 
For a full list of error codes, see Errors.
 
==Return==
'''ulrc (APIRET) - returns'''
 
Return Code.
 
DosDevConfig returns one of the following values:
 
NO_ERROR
87


ERROR_INVALID_PARAMETER
==Return Code==
 
;ulrc (APIRET) - return:DosDevConfig returns one of the following values:
For a full list of error codes, see Errors.
* 0 - NO_ERROR
* 87 - ERROR_INVALID_PARAMETER


==Example Code==
==Example Code==
   
This example gets information about the installed devices and displays it. Some return code checking was omitted for brevity.
This example gets information about the installed devices and displays it.
<code>
Some return code checking was omitted for brevity.
#define INCL_DOSDEVICES  /* Device values */
 
 
<pre> #define INCL_DOSDEVICES  /* Device values */
  #define INCL_DOSERRORS    /* Error values */
  #define INCL_DOSERRORS    /* Error values */
  #include &lt;os2.h&gt;
  #include <os2.h>
  #include &lt;stdio.h&gt;
  #include <stdio.h>
 
int main(VOID) {
int main(VOID) {
 
  BYTE Model      = 0,  /* Model number */
  BYTE    Model      = 0,  /* Model number */
         SubModel  = 0,  /* Submodel */
         SubModel  = 0,  /* Submodel */
         Adapter    = 0,  /* Display adapter type */
         Adapter    = 0,  /* Display adapter type */
         CoProc    = 0,  /* Math coprocessor installed? */
         CoProc    = 0,  /* Math coprocessor installed? */
         Printers  = 0;  /* Number of printers */
         Printers  = 0;  /* Number of printers */
 
APIRET rc         = NO_ERROR; /* Return code */
  APIRET rc       = NO_ERROR; /* Return code */
 
    rc = DosDevConfig(&amp;Model, DEVINFO_MODEL);
  rc = DosDevConfig(&Model, DEVINFO_MODEL);
    if (rc != NO_ERROR) {
  if (rc != NO_ERROR) {
       printf("DosDevConfig error:  return code = %u\n", rc);
       printf("DosDevConfig error:  return code = %u\n", rc);
       return 1;
       return 1;
    }
  }
 
    rc = DosDevConfig(&amp;SubModel, DEVINFO_SUBMODEL);
  rc = DosDevConfig(&SubModel, DEVINFO_SUBMODEL);
    printf("    Model/SubModel:  %d / %d\n", Model, SubModel);
  printf("    Model/SubModel:  %d / %d\n", Model, SubModel);
 
    rc = DosDevConfig(&amp;Adapter, DEVINFO_ADAPTER);
  rc = DosDevConfig(&Adapter, DEVINFO_ADAPTER);
    printf("      Display type:  %s\n", (Adapter ? "Color" : "Monochrome"));
  printf("      Display type:  %s\n", (Adapter ? "Color" : "Monochrome"));
 
    rc = DosDevConfig(&amp;CoProc, DEVINFO_COPROCESSOR);
  rc = DosDevConfig(&CoProc, DEVINFO_COPROCESSOR);
    printf(" Math co-processor?  %s\n", (CoProc ? "Yes" : "No"));
  printf(" Math co-processor?  %s\n", (CoProc ? "Yes" : "No"));
 
    rc = DosDevConfig(&amp;Printers, DEVINFO_PRINTER);
  rc = DosDevConfig(&Printers, DEVINFO_PRINTER);
    printf("Number of printers:  %d\n", Printers);
  printf("Number of printers:  %d\n", Printers);
 
    return NO_ERROR;
  return NO_ERROR;
}
}
 
</code>
</pre>


==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosBeep|CPI:DosBeep]]
* [[DosBeep]]
* [[OS2 API:CPI:DosDevIOCtl|CPI:DosDevIOCtl]]
* [[DosDevIOCtl]]
* [[OS2 API:CPI:DosPhysicalDisk|CPI:DosPhysicalDisk]]
* [[DosPhysicalDisk]]
 


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 07:13, 16 December 2018

Gets information about attached devices.

Syntax

DosDevConfig(pdevinfo, item)

Parameters

pdevinfo (PVOID) - output
Address of the area where the information is returned.
All returned device information is BYTE-sized, so this should be the address of a BYTE variable.
item (ULONG) - input
Device information to be returned.
This parameter has one of the possible values:
0 DEVINFO_PRINTER: Number of parallel or printer ports.
1 DEVINFO_RS232: Number of RS232 ports.
2 DEVINFO_FLOPPY: Number of diskette drives.
3 DEVINFO_COPROCESSOR: Presence of math coprocessor hardware:
0 No coprocessor hardware
1 Coprocessor hardware installed
4 DEVINFO_SUBMODEL: PC Submodel Type. The returned information is the system submodel byte.
5 DEVINFO_MODEL: PC Model Type. The returned information is the system model byte.
6 DEVINFO_ADAPTER: Type of primary display adapter:
0 Monochrome or printer adapter
1 Other

Return Code

ulrc (APIRET) - return
DosDevConfig returns one of the following values:
  • 0 - NO_ERROR
  • 87 - ERROR_INVALID_PARAMETER

Example Code

This example gets information about the installed devices and displays it. Some return code checking was omitted for brevity.

#define INCL_DOSDEVICES   /* Device values */
#define INCL_DOSERRORS    /* Error values */
#include <os2.h>
#include <stdio.h>

int main(VOID) {
  BYTE  Model      = 0,  /* Model number */
        SubModel   = 0,  /* Submodel */
        Adapter    = 0,  /* Display adapter type */
        CoProc     = 0,  /* Math coprocessor installed? */
        Printers   = 0;  /* Number of printers */

  APIRET rc        = NO_ERROR; /* Return code */

  rc = DosDevConfig(&Model, DEVINFO_MODEL);
  if (rc != NO_ERROR) {
      printf("DosDevConfig error:  return code = %u\n", rc);
      return 1;
  }

  rc = DosDevConfig(&SubModel, DEVINFO_SUBMODEL);
  printf("    Model/SubModel:  %d / %d\n", Model, SubModel);

  rc = DosDevConfig(&Adapter, DEVINFO_ADAPTER);
  printf("      Display type:  %s\n", (Adapter ? "Color" : "Monochrome"));

  rc = DosDevConfig(&CoProc, DEVINFO_COPROCESSOR);
  printf(" Math co-processor?  %s\n", (CoProc ? "Yes" : "No"));

  rc = DosDevConfig(&Printers, DEVINFO_PRINTER);
  printf("Number of printers:  %d\n", Printers);

  return NO_ERROR;
}

Related Functions