Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Howto detect if a printer is offline or turned off


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Feb 15, 2018 6:08 PM Last Post By: Remy Lebeau (Te...
Michael Eriksen

Posts: 27
Registered: 6/12/11
Howto detect if a printer is offline or turned off  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2018 11:39 AM
Hello all,

I have a printer that is turned off or is offline - is it possible via a Delphi boolean routine to check for that?
A routine that returns True if a given printername is Online and False if a given printername is Offline(turned off).

Thanks in advance,
Regards Michael Eriksen
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Howto detect if a printer is offline or turned off  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 15, 2018 6:07 PM   in response to: Michael Eriksen in response to: Michael Eriksen
Michael Eriksen wrote:

I have a printer that is turned off or is offline - is it possible
via a Delphi boolean routine to check for that?

You can't get that information from the VCL's TPrinter class. You have
to open the desired printer by calling the Win32 API OpenPrinter()
function directly (which TPrinter does use internally, but doesn't
expose access to the opened HANDLE), and then call the Win32 API
GetPrinter() function with its Level parameter set to 2 or 6 to
retrieve status information.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd162751.aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/dd144911.aspx

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02