List local printers
Posted
by vladimir
on Stack Overflow
See other posts from Stack Overflow
or by vladimir
Published on 2010-04-08T15:09:47Z
Indexed on
2010/04/08
15:13 UTC
Read the original article
Hit count: 288
delphi-2010
hi all,
i am using this routine to list the local printers installed on on a machine...
var p: pointer; hpi: _PRINTER_INFO_2A; hGlobal: cardinal; dwNeeded, dwReturned: DWORD; bFlag: boolean; i: dword; begin p := nil; EnumPrinters(PRINTER_ENUM_LOCAL, nil, 2, p, 0, dwNeeded, dwReturned); if (dwNeeded = 0) then exit; GetMem(p,dwNeeded); if (p = nil) then exit; bFlag := EnumPrinters(PRINTER_ENUM_LOCAL, nil, 2, p, dwneeded, dwNeeded, dwReturned); if (not bFlag) then exit; CbLblPrinterPath.Properties.Items.Clear; for i := 0 to dwReturned - 1 do begin CbLblPrinterPath.Properties.Items.Add(TPrinterInfos(p^)[i].pPrinterName); end;
FreeMem(p);
TPrinterInfos(p^)[i].pPrinterName returns a 'P' for printer name. i have a PdfCreator installed as a printer.
TPrinterInfos is an array of _PRINTER_INFO_2A.
how can i fix this?
© Stack Overflow or respective owner