不行,不信你自己试试。全用设的第一个打印机打出来了。
procedure TCT1.BitBtn1Click(Sender: TObject);
var
LPrinter:string;
PrinIniFile:Tinifile;
LStr:string;
begin
LStr:='\\192.168.1.6\HP LaserJet 1020';
StringUtils.delete(Lstr,StringUtils.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;
Borland.Delphi.Windows.SendMessage (Borland.Delphi.Windows.HWND_BROADCAST,
Borland.Delphi.Messages.WM_SETTINGCHANGE, 0, 0);
end;
TSheetDoc(DocView1.doc).Exporter.Printex(false, false);
// 第二个打印
LStr:='Microsoft Office Document Image Writer';
StringUtils.delete(Lstr,StringUtils.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;
Borland.Delphi.Windows.SendMessage (Borland.Delphi.Windows.HWND_BROADCAST,
Borland.Delphi.Messages.WM_SETTINGCHANGE, 0, 0);
end;
TSheetDoc(DocView2.doc).Exporter.Printex(false, false);
end; |