GetDefaultPrinter ()

From ISXKB

Revision as of 11:54, 25 January 2008 by Markus (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

This article shows how to use the Windows API function GetDefaultPrinter with Inno Setup. It is derived from a post from Gavin Lambert.

Declaration

The following declaration is required in a [Code] section:

function GetDefaultPrinter (pszBuffer: String; var cchBuffer: Integer): LongBool;
 external 'GetDefaultPrinterA@winspool.drv stdcall';

GetDefaultPrinter () at MSDN

Example Code

   BufLen := 128;  // adjust as needed
   Buffer := StringOfChar (#0, BufLen);
   if (GetDefaultPrinter (PChar(Buffer), BufLen)) then begin
     SetLength (Buffer, BufLen);
     // ...do something with Buffer
   end else begin
     // ...show an error message
   end;
Personal tools
Ads: