I am trying to implement thhe scanning options using twain drivers. If i have my scanner turned off, the program still detect that a twain driver was installed and will give me an out of bound error trying to initialize that. I also tried the twain demo that gives the same result. i have: for i:=0 to imageenvect.io.twainparams.sourcecount -1 do ....//filling up a combobox
Is there a way i can detect if a scanner is turned on to avoid the error if not. Thanks. Pierre
I found out by using if imageenvect.io.twainparams.sourcecount >0 then enable button will prevent enabling the scanning button. Thanks for the answer. P PS: If your scanner is turned off and you try your command, I think you get the error.
Nope, that is still not working. The issue with the twain driver is that it is always there even if the scanner is not connected. So the imageenvect.io.twainparams.sourcecount is always greater than 0. That does not happen with WIA. If the scanner is not connected, no WIA is loaded. I need to find away to fill up my combobox with scanner name only if the scanners are turned on. I do not want to have a requester asking me to chose a scanner like with ImageEnView1.IO.SelectAcquireSource(ieaTWain); Anyway to detect in the background if a twai scanner is turned on or off? Thanks. P
Unfortunately I don't know a way to know if a scanner is connected or not. The twainparams.sourcecount list is read directly from the operating system (TWain device manager).