Forum Replies Created
- AuthorPosts
- September 16, 2011 at 3:59 pm in reply to: CAP_DEVICEONLINE always return false or suppress messagebox #25487
For anyone who has this problem and works in .NET then ignore tring to do this through the Twain drivers and go this direction.
Public Shared Function GetUSBDeviceStatus() As Boolean
Try
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObjectmoSearch = New Management.ManagementObjectSearcher(“Select * from Win32_USBControllerDevice”)
moReturn = moSearch.Get
For Each mo In moReturn
Dim moReturnDevice As Management.ManagementObjectCollection
Dim moSearchDevice As Management.ManagementObjectSearcher
Dim moDevice As Management.ManagementObject
Dim strDeviceName As String = mo(“Dependent”).ToString.Replace(“”””c, “”)
Dim strDevice As String = strDeviceName.Substring(strDeviceName.IndexOf(“=”) + 1)moSearchDevice = New Management.ManagementObjectSearcher(“Select * From Win32_PnPEntity Where DeviceID = ‘” & strDevice & “‘”)
moReturnDevice = moSearchDevice.GetFor Each moDevice In moReturnDevice
If Not moDevice.Item(“Service”) Is Nothing AndAlso Not moDevice.Item(“Status”) Is Nothing Then
If moDevice.Item(“Service”).ToString.Trim.ToLower.Equals(“usbscan”) And moDevice.Item(“Status”).ToString.Trim.ToLower.Equals(“ok”) Then
Return True
End If
End If
Next
NextReturn False
Catch ex As Exception
Return False
End TryEnd Function
Hi, Did you find a solution to your post? I am having the same problem…
My problem… My form is being loaded as modal. When attempting to scan the form is calling a Twain function “DSMident” and if the power if off on the scanner then a message is being display from the scanner driver. Since my form is modal I cannot close the message and it gives the appearance the application is frozen. I tried implementing the twain capability of CAP_DEVICEONLINE and it always returns false.
Dim capDeviceOnline As New TwCapability(TwCap.CAP_DEVICEONLINE)
rc = DScap(appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.[Get], capDeviceOnline)
If rc <> TwRC.Success Then
CloseSrc()
Return False
End IfVB.net on Windows 7 64 bit. Application is set as x86 using Twain_32.dll. Scanner is Canon DR-6010C.
- AuthorPosts