用INI保存记录
procedure TFrmMain.N8Click(Sender: TObject);
var
i:integer;
TmpFile,TmpPath:String;
MyIni:TIniFile;
begin
Try
if PrinterSetupDialog1.Execute then
begin
TmpPath:=ExtractFilePath(Application.ExeName);
MyIni:=TIniFile.Create(TmpPath+'/System.ini');
MyIni.WriteString('PrintName','PrtName',Printer.Printers.Strings[Printer.Printerindex]);
end;
finally
FreeAndNil(MyIni);
end;
end;
打印之前读去设定
Procedure SetPrinter;
var
TmpFile,TmpPath:String;
i:Integer;
IsDierection:Boolean;
MyIni:TIniFile;
begin
Try
TmpPath:=ExtractFilePath(Application.ExeName);
MyIni:=TIniFile.Create(TmpPath+'/System.ini');
//poLandscape 横向 poPortrait垂直;
//TmpFile:=MyIni.ReadString('Print','Direction','');
//if TmpFile='0' then
Printer.Orientation:=poLandscape else
Printer.Orientation:=poPortrait;
//指定默认的打印机
TmpFile:=MyIni.ReadString('PrintName','PrtName','');
for i:=0 to Printer.Printers.Count-1do
if Printer.Printers.Strings=TmpFile then
Printer.PrinterIndex:=i;
finally
freeandnil(MyIni);
end;
end.