PrfQueryProfileString - Example Code

PrfQueryProfileString is issued twice to obtain the names of the default printer, the default presentation driver, and the queue associated with the printer. If any of these requests fails, the default values already defined in DEVOPENSTRUC are used.

#define INCL_WINSHELLDATA
#include <OS2.H>
char szTemp[80];
char szBuff[257];
PCH ptscan;

DEVOPENSTRUC dopPrinter = {"LPT1Q",
                          (PSZ)"IBM4201",
                           0L,
                          (PSZ)"PM_Q_STD",
                           0L, 0L, 0L, 0L, 0L};

  if (PrfQueryProfileString(HINI_PROFILE,
                           (PSZ)"PM_SPOOLER",
                           (PSZ)"PRINTER",
                            NULL,
                           (PVOID)szTemp,
                           (LONG)sizeof(szTemp)
                           )){
      szTemp[strlen(szTemp)-1] = 0;
      if (PrfQueryProfileString(HINI_PROFILE,
                               (PSZ)"PM_SPOOLER_PRINTER",
                               (PSZ)szTemp,
                                NULL,
                               (PVOID)szBuff,
                               (LONG)sizeof(szBuff)
                               )){

          ptscan = (PCH)strchr(szBuff, ';');
          ptscan++;
          ptscan = (PCH)strchr(ptscan, (INT)';');
          ptscan++;
          *(ptscan + strcspn(ptscan, ".,;")) = 0;
          dopPrinter.pszLogAddress =  ptscan;

          ptscan = (PCH)strchr(szBuff, (INT)';');
          ptscan++;
          *(ptscan + strcspn(ptscan, ".,;")) = 0;
          dopPrinter.pszDriverName = ptscan;

      }
  }


[Back: PrfQueryProfileString - Related Functions]
[Next: PrfQueryProfileString - Topics]