我想用一个程序修改打印机设置后,永久的修改打印设置,而不是动态修改后,程序关闭后又恢复原来的。(过程中不能弹出系统打印设置对话框)

解决方案 »

  1.   

    unit printerset;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, 
    Dialogs,StdCtrls, ComCtrls, ExtCtrls,printers;type
      TForm1 = class(TForm)
        PrinterSetupDialog1: TPrinterSetupDialog;
        Button1: TButton;
        ComboBox1: TComboBox;
        Label1: TLabel;
        Label2: TLabel;
        RadioGroup1: TRadioGroup;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    begin
      printer.PrinterIndex:=combobox1.ItemIndex;
      formcreate(self);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
       printer.BeginDoc;
       printer.Canvas.TextOut(10,20,'hello'+label1.Caption);
       printer.EndDoc;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      with combobox1 do
        begin
          Clear;
          items.Assign(printer.Printers);
          itemindex:=printer.PrinterIndex;
        end;
      label1.Caption:=printer.printers[printer.printerindex];
      label2.Caption:='Width: '+Inttostr(printer.pageWidth)
      label2.Caption:=label2.Caption+' Height: '+inttostr(Printer.PageHeight);
      case printer.Orientation of
        PoPortrait:RadioGroup1.ItemIndex:=0;
        PoLandscape: RadioGroup1.ItemIndex:=1;
      end;
    end;end.