var
adevice,adriver,aport:array [0..255] of char;
devicehandle:thandle;
devmode
devicemode;
begin
printer.GetPrinter(adevice,adriver,aport,devicehandle);
if devicehandle=0 then
begin
printer.PrinterIndex:=printer.PrinterIndex;
printer.GetPrinter(adevice,adriver,aport,devicehandle);
end;
if devicehandle<>0 then
devmode:=GlobalLock(devicehandle);
printer.GetPrinter(adevice,adriver,aport,devicehandle);
if devicehandle=0 then
begin
printer.PrinterIndex:=printer.PrinterIndex;
printer.GetPrinter(adevice,adriver,aport,devicehandle);
end;
if Devicehandle=0 then
Raise Exception.Create('无法初始化设备,请检查')
else
DevMode:=GlobalLock(DeviceHandle);
with devmode^do
begin
dmFields := dmFields or DM_PAPERSIZE;
dmPaperSize := DMPAPER_USER;
dmFields := dmFields or DM_PAPERWIDTH;
dmPaperWidth := 2100;//纸宽
dmFields := dmFields or DM_PAPERLENGTH;
dmPaperlength:= 2970;//纸长
end;
IF NOT DEvicehandle=0 then
GlobalUnlock(DeviceHandle);
end;
end;