Microsoft KB Archive/264036

{|
 * width="100%"|

HOWTO: Determine Whether a Printer Is a PostScript Printer

 * }

Q264036

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), version 4.0
 * Microsoft Windows 98
 * Microsoft Windows 95
 * Microsoft Windows NT Server version 4.0
 * Microsoft Windows NT Workstation version 4.0

-

SUMMARY
It is necessary sometimes to determine whether or not a printer is a PostScript printer, so that an application can determine whether or not it can safely send raw PostScript data to the printer. The code in this article demonstrates one way to make this determination.

MORE INFORMATION
The code first tests for support of the POSTSCRIPT_PASSTHROUGH printer escape function, assuming that if the escape function is supported then the printer must be a PostScript printer. If the printer does not support the escape function, the second half of the code uses the GETTECHNOLOGY escape function to determine whether the technology string contains the text &quot;postscript&quot;. If the driver doesn't support the escape, it is assumed that it is not a PostScript printer.

BOOL IsDCPostscript( HDC hDC ) {   int     nEscapeCode; TCHAR  szTechnology[MAX_PATH] = TEXT(&quot;&quot;);

// If it supports POSTSCRIPT_PASSTHROUGH, it must be PS.   nEscapeCode = POSTSCRIPT_PASSTHROUGH; if( ExtEscape( hDC, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&nEscapeCode, 0, NULL ) > 0 ) return TRUE;

// If it doesn't support GETTECHNOLOGY, we won't be able to tell. nEscapeCode = GETTECHNOLOGY; if( ExtEscape( hDC, QUERYESCSUPPORT, sizeof(int), (LPCSTR)&nEscapeCode, 0, NULL ) <= 0 ) return FALSE;

// Get the technology string and check to see if the word &quot;postscript&quot; is in it. if( ExtEscape( hDC, GETTECHNOLOGY, 0, NULL, MAX_PATH, (LPSTR)szTechnology ) <= 0 ) return FALSE; strupr( szTechnology ); if( strstr( szTechnology, &quot;POSTSCRIPT&quot; ) == NULL ) return FALSE;

// The word &quot;postscript&quot; was not found and it didn't support //  POSTSCRIPT_PASSTHROUGH, so it's not a PS printer. return FALSE; } Additional query words: postscript ps raw data printer queue direct determine support

Keywords : kbGDI kbPrinting kbSDKPlatform kbSDKWin32 _IK kbGrpDSGDI

Issue type : kbhowto

Technology : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT400xsearch kbWinNTSsearch kbWinNTS400xsearch kbWinNTS400 kbWin32SDKSearch kbAudDeveloper kbWin95search kbWin98search kbSDKSearch kbZNotKeyword3 kbWin32sSearch kbWin32SDK400 kbWin98