Author Topic: How to check if a device is present?  (Read 13449 times)

moelski

  • Member
  • ***
  • Posts: 12
How to check if a device is present?
« on: October 30, 2012, 10:52:03 am »
Hi !

I can run SetupDiGetClassDevs with flags:
Code: [Select]
           var flags = onlyPresent
                        ? DsSetupApi.DIGCF_PRESENT | DsSetupApi.DIGCF_DEVICEINTERFACE
                        : DsSetupApi.DIGCF_DEVICEINTERFACE;
            deviceInfoSet = DsSetupApi.SetupDiGetClassDevs(ref guidToCheck, IntPtr.Zero, IntPtr.Zero, flags);
And this works great.

But how can I detect if a device is present or not if I use only DIGCF_DEVICEINTERFACE?

Is there any flag I can check or must I perform a CreateFile and check the error in order to check if it´s present or not?

Greetings
   Dominik

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to check if a device is present?
« Reply #1 on: October 31, 2012, 08:03:23 pm »
Why not use DIGCF_present?