用API,我在98和2000上试过,没问题.
procedure InitPrinter(PWidth, PHeight: Short);//单位为mm
var
hDMode: THandle;
PDMode: PDEVMODE;
Device,Driver,Port: array[0..255] of char;
begin
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then
begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then
begin
pDMode^.dmFields := pDMode^.dmFields or DM_PAPERSIZE or DM_PAPERWIDTH or DM_PAPERLENGTH;
pDMode^.dmPaperSize := DMPAPER_USER;
pDMode^.dmPaperWidth := PWidth;
pDMode^.dmPaperLength := PHeight;
GlobalUnlock(hDMode);
end;
end;
Printer.PrinterIndex := Printer.PrinterIndex;
end;