type pdevmode=^tdevmode;
tprinterdev=class
driver:string;
device:string;
port:string;
procedure tform1.setprinter;
var devs
devmode;
devsp
ointer;
devsize:integer;
printerobject:THandle;
devname:string;
begin
printerobject:=printer.handele;
devname:=tprinterdev(printer.printers.objects[printer.printerindex]).device;
devsize:=documentproperties(0,printerobject,pchar(devname),devs,devs,0);
devsp:=allocmem(devsize);
try
do
cumentproperties(0,printerobject,pchar(devname),devsp,nil,dm_out_buffer);
devs:=devsp;
devs^.dmdmfields:=dm_papersize;
devs^.dmpapersize:=dmpaper_fanfold_us;
//在这里换成你想要的纸张
//下面是自定义纸张
//如果使用的是 User_define自定义纸张
//那上面应该为
//devs^.dmfields:=dm_papersize or m_paperlength or dm_paperwidth;
//devs^.dmpapersize:=0;
//devs^dmpaperlength:=//changdu
//devs^.dmpaperwidth:=//width
do
cumentproperties(0,printerobject,pchar(devname),devsp,devsp,dm_out_buffer or dm_in_buffer);
finally
freemem(devsp,devsize);
end;
end;
end.