made DoEnumPrinters more robust from Ere Maijala

git-svn-id: trunk@7653 -
This commit is contained in:
vincents 2005-09-09 13:01:39 +00:00
parent 38ba258a2a
commit a966e4a9bb
2 changed files with 13 additions and 8 deletions

View File

@ -261,7 +261,6 @@ Var Flags : DWORD;
InfoPrt : PChar; InfoPrt : PChar;
i : Integer; i : Integer;
DefaultPrinter : array[0..79] of Char; DefaultPrinter : array[0..79] of Char;
LstStr : TStringList;
PDev : TPrinterDevice; PDev : TPrinterDevice;
begin begin
@ -310,13 +309,18 @@ begin
if Level=2 then if Level=2 then
begin begin
PDev:=TPrinterDevice.Create; PDev:=TPrinterDevice.Create;
PDev.Name :=PPRINTER_INFO_2(InfoPrt)^.pPrinterName; PDev.Name :=PPRINTER_INFO_2(InfoPrt)^.pPrinterName;
PDev.Device :=PPRINTER_INFO_2(InfoPrt)^.PDevMode^.dmDeviceName; PDev.Driver:=PPRINTER_INFO_2(InfoPrt)^.pDriverName;
PDev.Driver :=PPRINTER_INFO_2(InfoPrt)^.pDriverName; PDev.Port :=PPRINTER_INFO_2(InfoPrt)^.pPortName;
PDev.Port :=PPRINTER_INFO_2(InfoPrt)^.pPortName; if PPRINTER_INFO_2(InfoPrt)^.PDevMode <> nil then begin
PDev.DevMode:=PPRINTER_INFO_2(InfoPrt)^.PDevMode^; PDev.DevMode:=PPRINTER_INFO_2(InfoPrt)^.PDevMode^;
PDev.DefaultPaper:=PPRINTER_INFO_2(InfoPrt)^.PDevMode^.dmPaperSize; PDev.Device:=PDev.DevMode.dmDeviceName;
PDev.DefaultPaper:=PDev.DevMode.dmPaperSize;
end
else begin
PDev.Device:='';
PDev.DefaultPaper:=0;
end;
if AnsiCompareText(PDev.Name,DefaultPrinter)<>0 then if AnsiCompareText(PDev.Name,DefaultPrinter)<>0 then
Lst.AddObject(PDev.Name,PDev) Lst.AddObject(PDev.Name,PDev)
else else

View File

@ -16,6 +16,7 @@ Curtis White
Darek Mazur Darek Mazur
Darius Blaszijk Darius Blaszijk
Dean Zobec Dean Zobec
Ere Maijala
Eric Chapman Eric Chapman
Erivelton Silva Erivelton Silva
Felipe Monteiro de Carvalho Felipe Monteiro de Carvalho