需要在平台中设置默认打印机时,请用下面的代码:
var
LPrinter:string;
PrinIniFile:Tinifile;
LStr:string;
begin
LStr:=Business.Forms.Printers.printer.Printers[Index]; //Index指定打印机序号
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;
end; |