I am currently working on an application for use with scanning an printing devices. I use the ManagementObjectSearcher in order to retrieve device names and Id's:

For example using
(Don't forget to add the reference to System.Management.dll in the framework 2.** folder if you're trying the code)

Dim searcher As New ManagementObjectSearcher("Select * from Win32_PnPEntity")
        Dim PnpDevice As ManagementObject
     
        For Each PnpDevice In searcher.Get()
            If Not PnpDevice("Service") Is Nothing Then
                If PnpDevice("Service").ToString().StartsWith("usbscan") Then
                   msgbox("Name").ToString
                end if
            end if
         next

There are various classes such as:
-CIM_LogicalDevice
-Win32_PnPEntity

Allow access to various properties-- most of which are read only.

Question: Is it possible through one of these classes to reset a scanning device that is already in use or check on its current status.

-CIM_LogicalDevice("Status")--Win32_PnPEntity("Status") return the value of "OK" when the scanner is in use by another application. So that property must not be what I'm looking for.

I just want to query the device and if it is in use (from a failed attempt or human error) reset the device. The object that calls the scanner/printer is waiting for an event handler(successful scan) that sometimes does not occur and I cannot dispose of the object locking the device up as "in use."

How do I free the device? Or would the solution be to create a timer which waits for the event handler which could contain a property flag set to true if it occurs. If the event doesn't occur in a given timeframe and the flag is false dispose the object?

Have a look at THIS link. Is this what you were looking for?

For more, other info -

Kodak

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.