home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / iapp300.zip / SAMPLES / PRTLIST.C < prev    next >
C/C++ Source or Header  |  1995-03-01  |  4KB  |  105 lines

  1. /************************************************************************/
  2. /*                    Print Query Sample Program                                            */
  3. /************************************************************************/
  4. /* Function        Display all connected printers.                                     */
  5. /* Author        (c) Copyright Infoline AG 1995                                    */
  6. /*                    Schaffhauserstrasse 121                                                */
  7. /*                    CH-8302 Kloten - Switzerland                                        */
  8. /*                    Phone: +41 1 803 07 06 / Fax: +41 1 881 17 55                */
  9. /* History        V3.00 01/Mar/1995 Andy Brunner    Initial program version    */
  10. /************************************************************************/
  11.  
  12. #define    INCL_BASE
  13. #define    USER_OS2
  14.  
  15. #include "user.h"                                /* Include the necessary files    */
  16. #include "iapp.h"                                /* Include IAPP user file            */
  17.  
  18. #define    MMF_NAME        "PrtQuery"
  19.  
  20. /*======================================================================*/
  21. /*    Function: main                                                                             */ 
  22. /*======================================================================*/
  23.  
  24. SHORT main(SHORT sArgCounter, PUCHAR *pszArgVariables)
  25. {
  26.     /*-------------------------------------------------------------------*/
  27.     /* Automatic variables                                                                 */ 
  28.     /*-------------------------------------------------------------------*/
  29.  
  30.     IAPP_MMF                hMMFFile                                = NULL;
  31.  
  32.     P_IAPP_PRINT_QUERY pxPrintQuery                        = NULL;
  33.  
  34.     USHORT                usBufferSize                        = 0;
  35.  
  36.     /*-------------------------------------------------------------------*/
  37.     /* Display program title                                                            */
  38.     /*-------------------------------------------------------------------*/
  39.  
  40.     printf("Print Query Sample Program Version 3.00 - (c) Copyright Infoline AG 1995\n");
  41.     printf("────────────────────────────────────────────────────────────────────────\n");
  42.     printf("\n");
  43.  
  44.     /*-------------------------------------------------------------------*/
  45.     /* Check program arguments                                                            */
  46.     /*-------------------------------------------------------------------*/
  47.  
  48.     if (sArgCounter != 1)
  49.     {
  50.         printf("Usage: PrtList\n");
  51.         exit(4);
  52.     }
  53.  
  54.     /*-------------------------------------------------------------------*/
  55.     /* Obtain current printer configuration                                        */
  56.     /*-------------------------------------------------------------------*/
  57.  
  58.     IAppPrintQuery(MMF_NAME);
  59.  
  60.     /*-------------------------------------------------------------------*/
  61.     /* Open the created memory mapped file                                            */
  62.     /*-------------------------------------------------------------------*/
  63.  
  64.     hMMFFile = IAppMMFOpen(MMF_NAME, 'R');
  65.  
  66.     /*-------------------------------------------------------------------*/
  67.     /* Display column title                                                                */
  68.     /*-------------------------------------------------------------------*/
  69.  
  70.     printf("Name         Server          Device   Driver                           Def\n");
  71.     printf("──────────── ─────────────── ──────── ──────────────────────────────── ───\n");
  72.  
  73.     /*-------------------------------------------------------------------*/
  74.     /* Read thru the memory mapped file and format the records                */
  75.     /*-------------------------------------------------------------------*/
  76.  
  77.     while (IAppMMFRead(hMMFFile, (PVOID) &pxPrintQuery, &usBufferSize))
  78.     {
  79.         printf("%-12.12s %-15.15s %-8.8s %-32.32s %s\n",
  80.             pxPrintQuery->szName,
  81.             pxPrintQuery->szServer,
  82.             pxPrintQuery->szDevice,
  83.             pxPrintQuery->szDriver,
  84.             pxPrintQuery->fDefault ? "Yes" : "No");
  85.     }
  86.  
  87.     /*-------------------------------------------------------------------*/
  88.     /* Close the memory mapped file                                                    */
  89.     /*-------------------------------------------------------------------*/
  90.  
  91.     IAppMMFClose(hMMFFile);
  92.  
  93.     /*-------------------------------------------------------------------*/
  94.     /* Delete the memory mapped file                                                    */
  95.     /*-------------------------------------------------------------------*/
  96.  
  97.     IAppMMFDelete(MMF_NAME);
  98.  
  99.     /*-------------------------------------------------------------------*/
  100.     /*    Return to caller                                                                      */
  101.     /*-------------------------------------------------------------------*/
  102.  
  103.     return (0);
  104. }
  105.