Тhe problem occurs only on two computers on the network.First is the server of the database and the other is a client.Both work with the same application. The server prints notes on his own printer with "bar" products, and the client with "kitchen" products. Notes are printed automatically with timer on 30 sec. Occasionally, the files that print to the printer are sent to the kitchen are printed on the server's printer.Both printers are defаult.There are no other printers attached to them.This happens on a few days (5-6) and continues till entire system restart. When I print manually note goes correctly to default chosen printer.Printers are connected through usb cable.They are different models and uses different drivers.Names are not same.
Let Windows manage my default printer is off. Turn off file and printer sharing is off. Both printers are not shared.
RichEdit1.Lines.SaveToFile (FileName);
Printer.PrinterIndex:=-1;
RichEdit1.Print (FileName);
sleep(1000);
I just need each Computer and app on it to print to its own printer when it is default
Just add a Printer.Refresh at the start of your code, so the list of printers is reloaded before using them. Looks like they change after your application starts (it has happened to me a few times, specially with network printers that can punctually lose connection).
Printer.Refresh;
RichEdit1.Lines.SaveToFile (FileName);
Printer.PrinterIndex:=-1;
RichEdit1.Print (FileName);
Sleep(1000);