home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / comqry.zip / comqry.c
C/C++ Source or Header  |  2001-03-06  |  3KB  |  58 lines

  1. /*(c) Copyright IBM Corp. 1997  All rights reserved.                 
  2.                                                                    
  3. This sample program is owned by International Business Machines    
  4. Corporation or one of its subsidiaries ("IBM") and is copyrighted  
  5. and licensed, not sold.                                            
  6.                                                                    
  7. You may copy, modify, and distribute this sample program in any    
  8. form without payment to IBM,  for any purpose including developing,
  9. using, marketing or distributing programs that include or are      
  10. derivative works of the sample program.                            
  11.                                                                    
  12. The sample program is provided to you on an "AS IS" basis, without 
  13. warranty of any kind.  IBM HEREBY  EXPRESSLY DISCLAIMS ALL         
  14. WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED  
  15. TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A    
  16. PARTICULAR PURPOSE.                                                
  17.                                                                    
  18. Some jurisdictions do not allow for the exclusion or limitation of 
  19. implied warranties, so the above limitations or exclusions may not 
  20. apply to you.  IBM shall not be liable for any damages you suffer  
  21. as a result of using, modifying or distributing the sample program 
  22. or its derivatives.                                                
  23.                                                                    
  24. Each copy of any portion of this sample program or any derivative  
  25. work,  must include a the above copyright notice and disclaimer of 
  26. warranty.                                                          */
  27.                                                                    
  28.  
  29. /* This code segment queries the system for the number
  30.    of COM ports available to the the system.  It implements
  31.    the DosDevConfig OS/2 API which can be used to query
  32.    many system configuration hardware components */
  33.  
  34.  
  35. #define INCL_DOSDEVICES   /* Device values */
  36. #define INCL_DOSERRORS    /* Error values */
  37. #include <os2.h>
  38. #include <stdio.h>
  39.  
  40. int main(VOID) {
  41.  
  42. BYTE    RS232      = 0;  /* Number of com ports*/
  43.  
  44. APIRET  rc         = NO_ERROR; /* Return code */
  45.  
  46.      rc = DosDevConfig(&RS232, DEVINFO_RS232);
  47.      if (rc != NO_ERROR) {
  48.         printf("DosDevConfig error:  return code = %u\n", rc);
  49.         return 1;
  50.      }
  51.  
  52.  
  53.      rc = DosDevConfig(&RS232, DEVINFO_RS232);
  54.      printf("Number of COM Ports:  %d\n", RS232);
  55.  
  56.      return NO_ERROR;
  57.  }
  58.