同意shbjkl( ID:1878308 )的!
动态的设立默认的打印机
其实,用程序自动控制,实现后台打印才是最好的方法!!!!
//////////可参考例程
begin
ListBox1.Items := Printer.Printers;
ListBox1.ItemIndex := Printer.PrinterIndex;
end;
{
procedure TForm1.Button2Click(Sender: TObject);
Var
FHandle : THandle;
HPrt : THandle;
PrtInfo5: PPrinterInfo5;
FDevice: array[0..79] of char;
FDriver: array[0..79] of char;
FPort: array[0..79] of char;
begin
Printer.PrinterIndex := ListBox1.ItemIndex;
Printer.GetPrinter (FDevice, FDriver, FPort, FHandle);
if FHandle = 0 then
begin
{driver not loaded}
Printer.PrinterIndex := Printer.PrinterIndex;
{-forces Printer object to load driver}
end;
{ if... }
Printer.GetPrinter (FDevice, FDriver, FPort, FHandle);
OpenPrinter(FDevice, HPrt, nil);
if HPrt = 0 then
raise(Exception.Create('Couldn''t open printer'));
try
PrtInfo5 := GetPrinterInfo5(HPrt);
PrtInfo5.Attributes := PrtInfo5.Attributes + PRINTER_ATTRIBUTE_DEFAULT;
SetPrinter(HPrt,5,PrtInfo5,PRINTER_CONTROL_SET_STATUS);
FreeMem(PrtInfo5);
finally
ClosePrinter(HPrt);
end;