ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Twain scanner : check if a device is connected
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

N.SOTO

France
1 Posts

Posted - Oct 09 2017 :  10:41:48  Show Profile  Reply
Hello,

I have to hide error dialog when a Twain scanner device is not connected.
So, I tried to detect if this one is online... not found.
Finally, I tried to find a solution/trick on this forum.

But each related post is old, so may be a solution has been found since.

Related posts :

https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=1510&SearchTerms=plugged
https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=720&SearchTerms=not,connected

So guys, Is it possible to do that ?


Thank you for your help.

Nicolas S. (from France)

w2m

USA
1990 Posts

Posted - Oct 09 2017 :  11:24:34  Show Profile  Reply
I tried a few times to figure this out, but all of my attempts failed, so I do not think this is possible. I tried all morning and wound up with this, but even this fails when a HP printer/scanner is powered off:
procedure TForm1.PrinterStatus1Click(Sender: TObject);
var
  iPrinterIndex: integer;
  pcbNeeded: DWORD;
  iPrinter: THandle;
  iPrinterName: array [0 .. 255] of char;
  iPrinterInfo2: PPrinterInfo2;
begin
  GetMem(iPrinterInfo2, 5000);
  try
    iPrinterIndex := GetDefaultPrinterIndex;
    StrPCopy(iPrinterName, Printer.Printers[iPrinterIndex]);
    if OpenPrinter(iPrinterName, iPrinter, nil) then
      if GetPrinter(iPrinter, 2, iPrinterInfo2, 5000, @pcbNeeded) then
        case iPrinterInfo2.Status of
          PRINTER_STATUS_BUSY:
            ShowMessage('The printer is busy.');
          PRINTER_STATUS_DOOR_OPEN:
            ShowMessage('The printer door is open.');
          PRINTER_STATUS_ERROR:
            ShowMessage('The printer is in an error state.');
          PRINTER_STATUS_INITIALIZING:
            ShowMessage('The printer is initializing.');
          PRINTER_STATUS_IO_ACTIVE:
            ShowMessage('The printer is in an active input/output state.');
          PRINTER_STATUS_MANUAL_FEED:
            ShowMessage('The printer is in a manual feed state.');
          PRINTER_STATUS_NO_TONER:
            ShowMessage('The printer is out of toner.');
          PRINTER_STATUS_NOT_AVAILABLE:
            ShowMessage('The printer is not available for printing.');
          PRINTER_STATUS_OFFLINE:
            ShowMessage('The printer is offline.');
          PRINTER_STATUS_OUT_OF_MEMORY:
            ShowMessage('The printer has run out of memory.');
          PRINTER_STATUS_OUTPUT_BIN_FULL:
            ShowMessage('The printers output bin is full.');
          PRINTER_STATUS_PAGE_PUNT:
            ShowMessage('The printer cannot print the current page.');
          PRINTER_STATUS_PAPER_JAM:
            ShowMessage('Paper is jammed in the printer');
          PRINTER_STATUS_PAPER_OUT:
            ShowMessage('The printer is out of paper.');
          PRINTER_STATUS_PAPER_PROBLEM:
            ShowMessage('The printer has a paper problem.');
          PRINTER_STATUS_PAUSED:
            ShowMessage('The printer is paused.');
          PRINTER_STATUS_PENDING_DELETION:
            ShowMessage('The printer is deleting a print job.');
          PRINTER_STATUS_PRINTING:
            ShowMessage('The printer is printing.');
          PRINTER_STATUS_PROCESSING:
            ShowMessage('The printer is processing a print job.');
          PRINTER_STATUS_TONER_LOW:
            ShowMessage('The printer is low on ink.');
          PRINTER_STATUS_USER_INTERVENTION:
            ShowMessage('The user needs to do something to the printer.');
          PRINTER_STATUS_WAITING:
            ShowMessage('The printer is waiting.');
          PRINTER_STATUS_WARMING_UP:
            ShowMessage('The printer is warming up.');
          PRINTER_STATUS_SERVER_UNKNOWN:
            ShowMessage('Printer server unknown.');
          PRINTER_STATUS_POWER_SAVE:
            ShowMessage('Printer in power saving mode.');
          PRINTER_STATUS_SERVER_OFFLINE:
            ShowMessage('Printer server is off line.');
          else
             ShowMessage('The printer is online and is ready to print.');
        end
      else
        Caption := IntToStr(GetLastError);
    ClosePrinter(iPrinter);
  finally
    if iPrinterInfo2 <> nil then
      FreeMem(iPrinterInfo2, 5000);
  end;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: