设置默认打印机纸张长度、宽度
procedure printer_set(aLength,aWidth :Integer);
var
Device:Array[0..256] of Char;
Driver:Array[0..256] of Char;
Port:Array[0..32] of Char;
hDMode:THandle;
pDMode
DevMode;
begin
Printer.GetPrinter(Device,Driver,Port,hDMode);
if hDMode<>0 then
pDMode:=GLobalLock(hDMode);
if pDMode<>nil then
begin
pDMode^.dmPaperSize:=256;
pDMode^.dmPaperLength:=aLength;//长
pDMode^.dmPaperWidth:=aWidth;//宽
pDMode^.dmFields:=pDMode^.dmFields or DM_PAPERSIZE;
pDMode^.dmFields:=pDMode^.dmFields or DM_PAPERLENGTH;
pDMode^.dmFields:=pDMode^.dmFields or DM_PAPERWIDTH;
end;
ResetDC(Printer.Handle,pDMode^);
GLobalUnLock(hDMode);
end;