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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Twain scanner : check if a device is connected

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
N.SOTO Posted - Oct 09 2017 : 10:41:48
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)
1   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Oct 09 2017 : 11:24:34
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