|
I am desperate so I appreciate any help.
I have an application that uses the Twain_32.dll for scanning. This application used some of the code off of the solution located at “http://www.codeproject.com/KB/dotnet/twaindotnet.aspx?msg=3699574”. Anyway, my problem is that I have a modal form that the user clicks a button to begin scanning. If the scanner power is off then the scanner’s driver displays a message box with an error stating that the device is not ready. This would not be an issue except it gets placed behind the modal form and gives the appearance that the application freezes. The source code call is below…
rc = DSMident(appid, IntPtr.Zero, TwDG.Control, TwDAT.Identity, TwMSG.OpenDS, srcds)
If rc <> TwRC.Success Then
Return False
End If
So when the DSMIdent call is being made then that is when the message box is being displayed so I cannot capture the value of “rc” at that time to prevent the message box from being displayed behind my modal form.
In trying to prevent this I attempted to check if the device is online with the code below. The problem with this is that is always returns false even if the scanner is online and ready.
Public Function IsDeviceOnline() As Boolean
Try
Dim rc As TwRC
Dim capDeviceOnline As New TwCapability(TwCap.CAP_DEVICEONLINE)
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.DeviceEvent, capDeviceOnline)
If rc <> TwRC.Success Then
CloseSrc()
Return False
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
Please help… I would greatly appreciate any guidance.
|