在WINDOWS2000下?

解决方案 »

  1.   

    http://borland.mblogger.cn/aiirii/posts/3412.aspx
      

  2.   

    [转]
    //sPrinterName----打印机名称
    //sCustomPaperName----自定义纸张类型名称
    //PaperSize----纸张尺寸(单位:毫米)
    //如果列表中已经有了同名纸张类型,则会返回false
    //
    function AddCustomForm(sPrinterName,sCustomPaperName:string;PaperSize:TSize):boolean;
    var
        pFI:pFORM_INFO_1;
        phpnt:THandle;
    begin
        result:=true;
        if openprinter(pchar(sPrinterName),phpnt,nil) then
        begin
            new(pFI);
            with pFI^ do
            begin
                Flags:=FORM_USER;
                pName:=pchar(sCustomPaperName);
                Size.cx:=PaperSize.cx * 1000;
                Size.cy:=PaperSize.cy * 1000;
                ImageableArea.Left:=0;
                ImageableArea.Top:=0;
                ImageableArea.Right:=Size.cx;
                ImageableArea.Bottom:=Size.cy;
                if not AddForm(phpnt,1,pFI) then result:=false;
                closeprinter(phpnt);
            end;
            Dispose(pFI);
        end
        else
            result:=false;
    end;调用实例:
    var
       s:TSize;
    begin
        s.cx:=300; //mm
        s.cy:=400; //mm
        if AddCustomForm('Star AR-3200+','新加的纸张类型',s) then
            showmessage('OK')
        else
            showmessage('Oh,MyGod!');
    ----------------------------------------------
    大家多看看MSDN呀,特别是这篇文章:
    HOWTO: How To Call Win32 Spooler Enumeration APIs Properly
      

  3.   


    上面面代码因该定义个类型:
    type
        pFORM_INFO_1=^FORM_INFO_1;如果要修改某个已经存在的纸张类型应该是用SetForm,查看有没有此类型用enumforms循环查找或根据GetForm函数返回的错误信息判断