Search code examples
c++usbtwain

Programmatically ascertain whether TWAIN scanner is turned on


I am using TWAIN in a C++ program to control an Epson scanner, and have most things working as intended, with one exception:

When the scanner is not turned on, and a scan command is sent I get an error window from Epson Scan: "Cannot communicate with the scanner. Make sure the scanner is turned on (etc)".

Rather than rely on this I would like to check that the scanner is turned on on launch of my program. Is there a way (using TWAIN or not - perhaps a scan of connected, powered-on USB devices?) of achieving this?


Solution

  • I found this project:

    EnumDevices project

    on CodeForge which I was able to cannibalise for my needs. I was able to use the logic to generate a list of CStrings containing device names, then just ran through that looking for "EPSON Scanner".