这是我原来的DELPHI3.0的设置纸张大小的程序。经DELPHI5.0编译后就失效。都是在2000下。
function setprin(const x,y:integer):boolean;
//ÉèÖÃÖ½ÕÅ´óС
var ad1,ad2,ap:array[0..255] of char;
dh:Thandle;
dm
devicemode;
begin
result:=true;
try
printer.GetPrinter(ad1,ad2,ap,dh);
if dh=0 then
begin
printer.PrinterIndex:=printer.PrinterIndex;
printer.GetPrinter(ad1,ad2,ap,dh);
end;
if dh=0 then
raise exception.Create('²»Äܳõʼ»¯´òÓ¡»ú')
else
dm:=globallock(dh);
if dh<>0 then
begin
globalunlock(dh);
with dm^do
begin
dmfields:=dmfields or DM_PAPERWIDTH or DM_PAPERLENGTH;
dmpapersize:=DMPAPER_USER;
dmpaperwidth:=x;//3400;
dmpaperlength:=y;//4500;
printer.SetPrinter(ad1,ad2,ap,dh);
end;
// if GetPaperWidth <3399 then
// messagebox(handle,'&Iuml;&micro;&Iacute;&sup3;&Auml;&not;&Egrave;&Iuml;&acute;ò&Oacute;&iexcl;&raquo;ú&micro;&Auml;&acute;ò&Oacute;&iexcl;&Ouml;&frac12;&Otilde;&Aring;&acute;ó&ETH;&iexcl;&sup2;&raquo;&Auml;&Uuml;&Acirc;ú×&atilde;&acute;ò&Oacute;&iexcl;&Egrave;&Icirc;&Icirc;&ntilde;&micro;&Auml;&ETH;è&Ograve;&ordf;&pound;&iexcl;',MB_ICONWARNING+MB_OK);
end;
except
result:=false;
end;
end;