Reputation: 2520
I've run into a strange problem.
My program is developped using Delphi7. On a client's computer, who is running Windows 7 64-bit, Printer.Printers.Count returns 0 even though there are multiple printers installed.
MS Word prints without problems and returns the correct list of printers.
Apparently, it used to work before on the same computer then stopped working at one point in the past.
There have been problems with the Spooler and network printers have been installed recently.
Of course it could cause the problem but it still doens't explain why Word sees the printers and Delphi doesn't.
Any ideas?
Thanks!
Edit: Running the program with elevated privileges solved the issue. The point goes to Martijn. Thanks!
Upvotes: 2
Views: 1404
Reputation: 13632
This sounds a bit like you’re running the program under elevated privileges (i.e. as administrator), where no printers have been installed, because they’re all under the user’s regular account.
Or vice-versa (printers installed as admin not accessible for program running with limited account privileges).
So I think this belongs on http://superuser.com.
Upvotes: 5
Reputation: 557
TPrinter.Printers use the external windows function EnumPrinters. if there is a problem should be with your host machine !!
You can test your application on a machine running the same OS "Windows 7 64bit" and if it run without problems then you can be sure the problem is not your Delphi code.
Upvotes: 5