OpenPrinter

  BOOL OpenPrinter(pPrinterName, phPrinter, pDefaults)    
  LPTSTR pPrinterName;    
  LPHANDLE phPrinter;    
  LPPRINTER_DEFAULTS pDefaults;    

The OpenPrinter function obtains a handle for the specified Printer. The pDefaults parameter allows an application to specify the Datatype and DevMode values to assign to subsequent Documents submitted via the StartDocPrinter API. However, these values can be overridden with the SetJob API, once a Document has been started.

Parameters

pPrinterName

Points to a null-terminated string that specifies the name of the Printer to open

phPrinter

Points to a variable to receive the opened printer handle.

pDefaults

Points to a PRINTER_DEFAULTS structure. This value can be NULL.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. To obtain extended error information, use the GetLastError function.