Adam
Adam

Reputation: 357

What alternatives are available to WMI for obtaining the state of a printer?

What options are available in C#/.NET to get the status of an installed printer? The only information we need is if the printer is on or off (we have a little indicator on the screen that says 'Printer ready' or 'Printer offline').

Our application is a small client running on an embedded PC. We've found that the WMI Windows process is running out of memory. Watching it on my development PC there appears to be a memory leak as the amount of memory it uses slowly creeps up. On an embedded device with limited memory this is unacceptable and we're finding after a couple of hours the application crashes.

Upvotes: 0

Views: 1637

Answers (1)

SwDevMan81
SwDevMan81

Reputation: 49978

I would try to resolve the memory leak, but if you cant find it, you could always use PInvoke calls (specifically GetPrinterData). See an example here (Note: There are also WMI posts that could help you compare what you have and see if you can find the memory leak)

Upvotes: 2

Related Questions