Missing initialisation in TppPrinterInfo.GetDeviceCapability
Hi,
lines 2199 - 2205 in ppPrintr.pas (version 16.03, but also in version
5.56 from 1685 on) are
try
{call windows api to determine how many paper sizes are
supported}
llItems := DeviceCapabilities(FDevice, FPort, lwCapability,
lResultBuf, nil);
except
end;
From our point of view llItems could be uninitialised if
Devicecapabilities throws an exception.
Eventhough we found out, that the count of DC_BINS and DC_BINNAMES
maybe different.
We suggest to patch the lines in this way:
try
{call windows api to determine how many paper sizes are
supported}
llItems := DeviceCapabilities(FDevice, FPort, lwCapability,
lResultBuf, nil);
if lwCapability in [DC_BINS, DC_BINNAMES] then
begin
if lwCapability = DC_BINS then
llItems2 := DeviceCapabilities(FDevice, FPort, DC_BINNAMES,
nil, nil)
else
llItems2 := DeviceCapabilities(FDevice, FPort, DC_BINS, nil,
nil);
if llItems <> llItems2 then
llItems := 0;
end;
except
llItems := 0;
end;
any discussion is welcome
TIA Carsten
lines 2199 - 2205 in ppPrintr.pas (version 16.03, but also in version
5.56 from 1685 on) are
try
{call windows api to determine how many paper sizes are
supported}
llItems := DeviceCapabilities(FDevice, FPort, lwCapability,
lResultBuf, nil);
except
end;
From our point of view llItems could be uninitialised if
Devicecapabilities throws an exception.
Eventhough we found out, that the count of DC_BINS and DC_BINNAMES
maybe different.
We suggest to patch the lines in this way:
try
{call windows api to determine how many paper sizes are
supported}
llItems := DeviceCapabilities(FDevice, FPort, lwCapability,
lResultBuf, nil);
if lwCapability in [DC_BINS, DC_BINNAMES] then
begin
if lwCapability = DC_BINS then
llItems2 := DeviceCapabilities(FDevice, FPort, DC_BINNAMES,
nil, nil)
else
llItems2 := DeviceCapabilities(FDevice, FPort, DC_BINS, nil,
nil);
if llItems <> llItems2 then
llItems := 0;
end;
except
llItems := 0;
end;
any discussion is welcome
TIA Carsten
This discussion has been closed.
Comments
Thanks for the feedback. For discussion about the source code, support@ is
preferred.
The code has not changed much from prior versions, for Delphi 2010 and
later, it was updated to support Unicode. There has not been any reports of
issues with that code. I'll add an except handling initialization as shown
below. There is code elsewhere in the class to handle buggy printer drivers
that return different numbers of PaperBins, BindNames. If you have printer
driver you want me to download and test, let me know.
try
{call windows api to determine how many paper sizes are supported}
llItems := DeviceCapabilities(FDevice, FPort, lwCapability, lResultBuf,
nil);
except
llItems := 0;
end;
Best regards,
-
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Nard Moseley (Digital Metaphors) hat uns dieses gebracht :
-
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com