OpenPrinter2 function winspool

Win32Result<bool> OpenPrinter2(
  1. PCWSTR? pPrinterName,
  2. Pointer<Pointer<NativeType>> phPrinter,
  3. Pointer<PRINTER_DEFAULTS>? pDefault,
  4. Pointer<PRINTER_OPTIONS>? pOptions,
)

Retrieves a handle to the specified printer, print server, or other types of handles in the print subsystem, while setting some of the printer options.

To learn more, see learn.microsoft.com/windows/win32/printdocs/openprinter2.

Implementation

Win32Result<bool> OpenPrinter2(
  PCWSTR? pPrinterName,
  Pointer<Pointer> phPrinter,
  Pointer<PRINTER_DEFAULTS>? pDefault,
  Pointer<PRINTER_OPTIONS>? pOptions,
) {
  resolveGetLastError();
  final result_ = _OpenPrinter2(
    pPrinterName ?? nullptr,
    phPrinter,
    pDefault ?? nullptr,
    pOptions ?? nullptr,
  );
  return .new(value: result_ != FALSE, error: GetLastError());
}