大疆phantom说明书:delphi中怎么样用Delphi控制Windows的默认打印机。

来源:百度文库 编辑:偶看新闻 时间:2024/04/30 01:22:28

1:设置默认打印机。

procedure TForm1.FormCreate(Sender: TObject);
begin
cb1.items.assign(printer.printers);
end;

procedure TForm1.Button1Click(Sender: TObject);
var LPrinter:string;
PrinIniFile:Tinifile;
LStr:string;
begin
LStr:=printer.Printers[cb1.itemindex];
delete(Lstr,pos(' on ',Lstr),Length(LStr));
PrinIniFile:=TIniFile.Create('WIN.ini');
try
LPrinter:=PrinIniFile.ReadString('Devices',LStr,'');
PrinIniFile.writestring('windows','device',LStr ',' LPrinter);
finally
PrinIniFile.free;
end;
end;

2:你可以用Printer.PrinterIndex来控制打印机。首先,你取得所有的打印机,找出哪台是
激光打印机,哪台是针式打印机,然后,根据各PrinterIndex不同,在打印时自己作出选择
就可以用不同的打印机打不同的内容了。也不用改系统的默认打印机。
3:多人接受答案了。