Solved

Getting printer information

Posted on 2002-07-17
4
151 Views
Last Modified: 2010-04-04
Hi,
I need to know if the printer is on-line before sending a report to it. Any idea?
Thanks

Fabio
0
Comment
Question by:binho
  • 2
4 Comments
 
LVL 2

Expert Comment

by:PeterLarsen
Comment Utility
You can use "GetPrinter" to receive info about any printer attached to your computer.
I dont know whether this also works with network printers or not.
0
 
LVL 3

Accepted Solution

by:
marcoszorrilla earned 50 total points
Comment Utility
From Torrys.

...detect Printer status?
Author: Colombo Gianluca  

function TestPrinterStatus(LPTPort: Word): Byte;
var
  Status: byte;
  CheckLPT: word;
begin
  Status := 0;
  if (LPTPort >= 1) and (LPTPort <= 3) then
  begin
    CheckLPT := LPTPort - 1;
    asm
      mov dx, CheckLPT;
      mov al, 0;
      mov ah, 2;
      int 17h;
      mov &Status, ah;
    end;
  end;
  Result := Status;
end;


{
  Pass in the LPT port number you want to check & get the following back:
  01h - Timeout
  08h - I/O Error
  10h - Printer selected
  20h - Out of paper
  40h - Printer acknowledgement
  80h - Printer not busy (0 if busy)

  Note:
  This function doesn't work under NT, it gives an access violation
  from the DOS interrupt call.
}

Best Regards.
Marcos.

0
 
LVL 3

Expert Comment

by:marcoszorrilla
Comment Utility
Mor Examples.

AssignFile(IMpresora,'lpt1');   // Impresora : TExtFile;
{$I-}
Rewrite(Impresora);
{$I+}
if ioresult<>0 then ERROR


With Assembler

function IsPrinter : Boolean;
Const
    PrnStInt  : Byte = $17;
    StRq      : Byte = $02;
    PrnNum    : Word = 0;  { 0 para LPT1, 1 para LPT2, etc. }
Var
  nResult : byte;
Begin  (* IsPrinter*)
Asm
   mov ah,StRq;
   mov dx,PrnNum;
   Int $17;
   mov nResult,ah;
end;
IsPrinter := (nResult and $80) = $80;
End;

Best Regards
Marcos.
0
 

Expert Comment

by:CleanupPing
Comment Utility
binho:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now