procedure GetPrintPaperList(var lstName, lstX, lstY: TStringList);<br>var<br> PaperNames: Pointer;<br> PaperSize: Pointer;<br> i, Rslt: integer;<br> hDMode: THandle;<br> Device, Driver, Port: array[0..255] of char;<br>begin<br> {$R-} //Turn range checking off.<br> lstName.Clear;<br> lstX.Clear;<br> lstY.Clear;<br> Printer.GetPrinter(Device, Driver, Port, hDMode);<br> Rslt := DeviceCapabilitiesA(Device, Port, DC_PAPERNAMES, nil, nil);<br> if Rslt &gt; 0 then<br> begin<br> GetMem(PaperNames, Rslt * 64);<br> try<br> if DeviceCapabilitiesA(Device, Port, DC_PAPERNAMES, PaperNames, nil) = -1<br> then<br> raise Exception.Create('DevCap Error');<br> for i := 0 to Rslt - 1 do<br> lstName.Add(StrPas(TPNames(PaperNames^)));<br> finally<br> FreeMem(PaperNames, Rslt * 64);<br> end;<br> end;<br> Rslt := DeviceCapabilitiesA(Device, Port, DC_PAPERSIZE, nil, nil);<br> if Rslt &gt; 0 then<br> begin<br> GetMem(PaperSize, Rslt * 64);<br> try<br> if DeviceCapabilitiesA(Device, Port, DC_PAPERSIZE, PaperSize, nil) = -1<br> then<br> raise Exception.Create('DevCap Error');<br> for i := 0 to Rslt - 1 do<br> begin<br> lstX.Add(IntToStr(TPSize(PaperSize^).x));<br> lstY.Add(IntToStr(TPSize(PaperSize^).y));<br> end;<br> finally<br> FreeMem(PaperSize, Rslt * 64);<br> end;<br> end;<br> {$R+} //Turn range checking back on.<br>end;