From: DeStefan on
Kerem,
Well IMHO you give the easiest solution for your problem aready yourself:
>> i either use DIGCF_PRESENT or the DIGCF_ALLCLASSES, depending
>> on what i need, but mostly i have to see ALL devices on my system, so the
>> point is to select between devices that are attached physically to my
>> system
>> and those who are not
As you wrote you just need to compare the return handles from DIGCF_PRESENT
against those with DIGCF_ALLCLASSES then you know exactly the difference.
If the handle is in the list with allclasses, but not in the list of present
devices, you can display the device and mark it as "not present".
Be also aware of the fact that a device may be present, but disabled. in
latter case you will get the device as present, but it will not work. to be
really sure, if it is working, you need to create a handle to the driver. if
device is disabled, you get an invalid handle.


"Stefan Kuhr" wrote:

> Kerem,
>
> Kerem Gümrükcü wrote:
> > Hi Pavel,
> >
> > i either use DIGCF_PRESENT or the DIGCF_ALLCLASSES, depending
> > on what i need, but mostly i have to see ALL devices on my system, so the
> > point is to select between devices that are attached physically to my
> > system
> > and those who are not,...there must be some flag somewhere or a SetupDi*
> > function that can do this for me,...
> >
> > Regards
> >
> > Kerem
> >
>
> In addition to what Wilhelm noeker wrote: You might want to do a
> CM_Get_DevNode_Status/CM_Get_DevNode_Status_Ex on the device node and
> examine the status for the device that is returned. If the flag
> DN_NO_SHOW_IN_DM is set, you can leave out that device.
>
> --
> S
>
From: Pavel A. on
Kerem G�mr�kc� wrote:
> Hi Pavel,
>
> i either use DIGCF_PRESENT or the DIGCF_ALLCLASSES, depending
> on what i need, but mostly i have to see ALL devices on my system, so the
> point is to select between devices that are attached physically to my
> system
> and those who are not,...there must be some flag somewhere or a SetupDi*
> function that can do this for me,...
>

Hi Kerem,

Use DIGCF_PRESENT to select _only_ devices that are currently attached.
This and DIGCF_ALLCLASSES are independent.

However - as Wilhelm Noeker wrote - attached devices can be either
working or having some problem (code 10, code 12, etc).
This you can see with CM_Get_DevNode_Status().

Regards,
--PA
From: Travis.Martin on
Pavel is correct, you can use BOTH flags at the same time in a call to
SetupDiGetClassDevs(...): Use the binary-OR operator to combine the flags
like so: (DIGCF_PRESENT | DIGCF_ALLCLASSES). Using the DIGCF_PRESENT flag is
slightly more efficient and is likely to be even more efficient in future
versions of Windows.

If you absolutly need to know about non-present devices (not many people
do), then CM_Get_DevNode_Status() is your best bet for distinguishing between
present and non-present.

Also, if you know the specific Interface class(es) of the devices you're
interested in, (DIGCF_DEVICEINTERFACE) the call will be much faster if you
give it each interface class one by one.

Future versions of Windows may also have significant speedups if you provide
a specific setup Class GUID to the call.

Thanks,
-=Travis.Martin

"Pavel A." wrote:

> Kerem Gümrükcü wrote:
> > Hi Pavel,
> >
> > i either use DIGCF_PRESENT or the DIGCF_ALLCLASSES, depending
> > on what i need, but mostly i have to see ALL devices on my system, so the
> > point is to select between devices that are attached physically to my
> > system
> > and those who are not,...there must be some flag somewhere or a SetupDi*
> > function that can do this for me,...
> >
>
> Hi Kerem,
>
> Use DIGCF_PRESENT to select _only_ devices that are currently attached.
> This and DIGCF_ALLCLASSES are independent.
>
> However - as Wilhelm Noeker wrote - attached devices can be either
> working or having some problem (code 10, code 12, etc).
> This you can see with CM_Get_DevNode_Status().
>
> Regards,
> --PA
>