locked
How to enumerate sideshow devices RRS feed

  • Question

  • I need to enumerate all sideshow devices attached in my platform.

    How to do it?

     

    The interface ISideShowCapabilities can enumerate the devices be enabled to output. But I want to enumerate all device attached.

     

     

    Tuesday, August 21, 2007 9:22 AM

Answers

  •  

    Hi,

     

    You can query the drivers/devices using the Setup API.  The Windows SDK and DDK documentation contains all the reference you need but essentially:

     

    - Use SetupDiGetClassDevs with the SideShow guid {997B5D8D-C442-4F2E-BAF3-9C8E671E9E21}, specify a NULL enumerator and use DIGCF_PRESENT if you want current devices, otherwise leave it NULL

    - Once you have a HDevInfo you can use SetupDiEnumDeviceInfo to retrieve SP_DEVINFO_DATA structures

    - With each SP_DEVINFO_DATA you can use SetupDiGetDeviceProperty or SetupDiGetDeviceRegistryProperty to extract the properties you would like.

    - Ensure that you close the HDevInfo with SetupDiDestroyDeviceInfoList

     

    The WDK/SDK will explain this much better than I have but essentially the basics are there.  This method also works quite successfully in C# if you want to write the imports.

     

    Am not sure if your process needs to be elevated but it'll probably be best.

     

    Hope this helps,

    -james

    Tuesday, August 21, 2007 5:10 PM

All replies

  •  

    Hi,

     

    You can query the drivers/devices using the Setup API.  The Windows SDK and DDK documentation contains all the reference you need but essentially:

     

    - Use SetupDiGetClassDevs with the SideShow guid {997B5D8D-C442-4F2E-BAF3-9C8E671E9E21}, specify a NULL enumerator and use DIGCF_PRESENT if you want current devices, otherwise leave it NULL

    - Once you have a HDevInfo you can use SetupDiEnumDeviceInfo to retrieve SP_DEVINFO_DATA structures

    - With each SP_DEVINFO_DATA you can use SetupDiGetDeviceProperty or SetupDiGetDeviceRegistryProperty to extract the properties you would like.

    - Ensure that you close the HDevInfo with SetupDiDestroyDeviceInfoList

     

    The WDK/SDK will explain this much better than I have but essentially the basics are there.  This method also works quite successfully in C# if you want to write the imports.

     

    Am not sure if your process needs to be elevated but it'll probably be best.

     

    Hope this helps,

    -james

    Tuesday, August 21, 2007 5:10 PM
  • Yes! It works. But it looks I can't get the simulator device instance. Why?

    Wednesday, August 22, 2007 12:33 PM
  •  Ares Lee wrote:

    Yes! It works. But it looks I can't get the simulator device instance. Why?

     

    I'm not sure why the Simulators are not enumerating; they should.  Are you using a device setup class GUID or a device interface GUID?  The SideShow device interface GUID is defined in the WDK header WindowsSideShowDriverEvents.h.  We use SetupDiGetClassDevsEx with the device interface GUID, and then enumerate that list with SetupDiEnumDeviceInterfaces.

     

    Dan

    Friday, September 7, 2007 4:18 PM
    Moderator
  • Hi,

     

    Here at Ikanos Consulting we've been writing a library to assist with the Setup API.  Using our new .NET library you can enumerate easily through devices, get/set device properties, send Control Codes etc.. using friendly .NET classes.

     

    e.g: to enumerate through all devices (including hidden) that expose the SideShow Interface:

     

    foreach (DeviceInstance devInst in SystemInterfaces.SideShow.AllDevices)

    {

    Debug.WriteLine(devInst.ToString());

    }

     

    or, to enumerate all present devices that belong to the SideShow Setup Class

     

    foreach (DeviceInstance devInst in DeviceClass.SideShow.Devices)

    {

    Debug.WriteLine(devInst.ToString());

    }

     

    As a sample, using our library we can easily open the CD ROM tray:

     

    //Create a DeviceCollection consisting of devices found in the CDROM Interface

    using (DeviceCollection devCol = SystemInterfaces.CDROM.Devices)

    {

    // Loop through each DeviceInstance in the collection

    foreach (DeviceInstance inst in devCol)

    {

    //Open a file to the device

    using (DeviceFileStream fs = inst.OpenFile(System.IO.FileAccess.Read))

    {

    // Send the IOCTL_STORAGE_EJECT_MEDIA Control Code to the device

    fs.DeviceIOControl(ControlCode.Storage.IOCTL_STORAGE_EJECT_MEDIA);

    }

    }

    }

     

    We are still putting the final touches to our first BETA release but if anybody is interested in trying this out, please email beta@ikanosconsulting.com.

     

     

    Friday, September 7, 2007 5:13 PM