Is there an easy way to detect if the scanner is connected or not?
I'd like the application I wrote to disable scanning features if the user disconnected the scanner.
Detect if scanner is connected?
Moderator: Alex
Re: Detect if scanner is connected?
Hello,
TWAIN standard does not allow to detect if device is on-line or not. You should try to open the device if you want to check device status.
Which scanner do you use? Some scanners send messages to application about their state (the power supply has been changed, the user has added a device, device has become unavailable and so on).
Best regards, Alexander
TWAIN standard does not allow to detect if device is on-line or not. You should try to open the device if you want to check device status.
Which scanner do you use? Some scanners send messages to application about their state (the power supply has been changed, the user has added a device, device has become unavailable and so on).
Best regards, Alexander
Re: Detect if scanner is connected?
My software is for remote invoice approval and is used by 120 users. Only 3 of which use an HP ScanJet 5590 to scan in the images.
So if I did the following in a try/catch block it would work?
bool bScannerConnected = false;
try {
Vintasoft.Twain.VSTwain td_Scanner = new Vintasoft.Twain.VSTwain();
td_Scanner.StartDevice();
td_Scanner.OpenDataSource();
bScannerConneced = true;
}
catch
{
}
So if I did the following in a try/catch block it would work?
bool bScannerConnected = false;
try {
Vintasoft.Twain.VSTwain td_Scanner = new Vintasoft.Twain.VSTwain();
td_Scanner.StartDevice();
td_Scanner.OpenDataSource();
bScannerConneced = true;
}
catch
{
}
Re: Detect if scanner is connected?
Yes, but you should specify correct exception type as follows:
Code: Select all
bScannerConneced = false;
Vintasoft.Twain.VSTwain td_Scanner = new Vintasoft.Twain.VSTwain();
try {
td_Scanner.StartDevice();
td_Scanner.OpenDataSource();
bScannerConneced = true;
}
catch (TwainException)
{
}
-
- Posts: 1
- Joined: Wed Oct 01, 2008 8:38 am
Re: Detect if scanner is connected?
When I call OpenDataSource without having a scanner attached I get a dialog box (text below). This happens BEFORE the TwainException is caught and is fairly obviously being generated by the Canon scanner's TWAIN driver (not VintaSoftTwain). Setting ShowUI = false before doing the OpenDataSource doesn't help.
Any suggestions for overcoming this behaviour?
Regards
Dean Rosenhain
---------------------------
ScanGear CS
---------------------------
Cannot communicate with scanner.
Cable may be disconnected or scanner may be turned off.
Check status.
Scanner driver will be closed.
---------------------------
OK
---------------------------
Any suggestions for overcoming this behaviour?
Regards
Dean Rosenhain
---------------------------
ScanGear CS
---------------------------
Cannot communicate with scanner.
Cable may be disconnected or scanner may be turned off.
Check status.
Scanner driver will be closed.
---------------------------
OK
---------------------------
Re: Detect if scanner is connected?
Hello Dean,
Unfortunately this dialog cannot be prevented because it's a custom dialog from the * of scanner.
Best regards, Alexander
Unfortunately this dialog cannot be prevented because it's a custom dialog from the * of scanner.
Best regards, Alexander