Hi,

Under control panel > Phone And Modem Options -> Modems tab, you can
see modems listed, such as USB modems, even if they are not attached.
When they are not attached, the "Attached To" column will show "Not
present".

I want to create such list myself, where it shows the description
(name) and modems, even if they are not attached.

I tried:


int _tmain(int argc, _TCHAR* argv[])
{
HWND hwndParent = NULL;
HDEVINFO hDevInfo;
SP_DEVINFO_DATA sdd;
sdd.cbSize = sizeof(SP_DEVINFO_DATA);

GUID guid;
if (RPC_S_OK != UuidFromString((RPC_WSTR)_T("4D36E96D-E325-11CE-
BFC1-08002BE10318"), &guid))
return -1;

hDevInfo = SetupDiGetClassDevs(
&guid,
NULL,
hwndParent,
DIGCF_PROFILE
);

if (INVALID_HANDLE_VALUE == hDevInfo)
return -1;


TCHAR szDeviceInstanceId[MAX_PATH];
DWORD i=0;
while(SetupDiEnumDeviceInfo(hDevInfo, i, &sdd)) {
if (SetupDiGetDeviceInstanceId(hDevInfo, &sdd, szDeviceInstanceId,
sizeof(szDeviceInstanceId)/sizeof(TCHAR), NULL)) {
// insert szDeviceInstanceId to a list
}
++i;
}
SetupDiDestroyDeviceInfoList(hDevInfo);
return 0;
}



However, when I uninstall the device, the above still lists its device
id (because the driver is still present, I think). And I don't want
this.

How can I list Unattached, BUT INSTALLED devices?

Lisa

Re: Listing Unattached modems by Maxim

Maxim
Fri Mar 14 17:58:13 CDT 2008

Do you have a DEVCON DDK/WDK sample source? can it do this?

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"Lisa Pearlson" <reageer@yahoo.com> wrote in message
news:5731f1d0-dadc-4c07-a811-889ca070bfd1@e25g2000prg.googlegroups.com...
> Hi,
>
> Under control panel > Phone And Modem Options -> Modems tab, you can
> see modems listed, such as USB modems, even if they are not attached.
> When they are not attached, the "Attached To" column will show "Not
> present".
>
> I want to create such list myself, where it shows the description
> (name) and modems, even if they are not attached.
>
> I tried:
>
>
> int _tmain(int argc, _TCHAR* argv[])
> {
> HWND hwndParent = NULL;
> HDEVINFO hDevInfo;
> SP_DEVINFO_DATA sdd;
> sdd.cbSize = sizeof(SP_DEVINFO_DATA);
>
> GUID guid;
> if (RPC_S_OK != UuidFromString((RPC_WSTR)_T("4D36E96D-E325-11CE-
> BFC1-08002BE10318"), &guid))
> return -1;
>
> hDevInfo = SetupDiGetClassDevs(
> &guid,
> NULL,
> hwndParent,
> DIGCF_PROFILE
> );
>
> if (INVALID_HANDLE_VALUE == hDevInfo)
> return -1;
>
>
> TCHAR szDeviceInstanceId[MAX_PATH];
> DWORD i=0;
> while(SetupDiEnumDeviceInfo(hDevInfo, i, &sdd)) {
> if (SetupDiGetDeviceInstanceId(hDevInfo, &sdd, szDeviceInstanceId,
> sizeof(szDeviceInstanceId)/sizeof(TCHAR), NULL)) {
> // insert szDeviceInstanceId to a list
> }
> ++i;
> }
> SetupDiDestroyDeviceInfoList(hDevInfo);
> return 0;
> }
>
>
>
> However, when I uninstall the device, the above still lists its device
> id (because the driver is still present, I think). And I don't want
> this.
>
> How can I list Unattached, BUT INSTALLED devices?
>
> Lisa


Re: Listing Unattached modems by chris

chris
Sat Mar 15 10:11:11 CDT 2008

On Mar 14, 5:38 pm, Lisa Pearlson <reag...@yahoo.com> wrote:

> However, when I uninstall the device, the above still lists its device
> id (because the driver is still present, I think). And I don't want
> this.

How are you "uninstalling" the device? Through Modem control panel or
Device Manager? This API doesn't know about "installed drivers".

The default is to show all devices, including unconnected devices.
You will only see "present" devices only if you pass DIGCF_PRESENT.

For each instance returned, you can call CM_Get_DevNode_Status() to
see if the device is connected or not.

Re: Listing Unattached modems by Lisa

Lisa
Sun Mar 16 13:41:15 CDT 2008

Well, I was mistaken in that uninstalling will no longer list the device.
So it seems to work, however, it is not what I was looking for.

If windows 'detects' my device, and asks for a driver, and I (or end user)
cancels the install, the device will show up under device manager with a
question-mark icon, for being unknown device.

When this happens, windows will no longer prompt for a driver next time this
device is attached, but my code will list this device's InstanceId same as
if the driver was properly installed.

So, what I need is also to get the driver details that are associated with
this device. Enumerating drivers by replacing

SetupDiEnumDeviceInfo(hDevInfo, i, &sdd)

by

SP_DRVINFO_DATA sdr;
sdr.cbSize = sizeof(sdr);
SetupDiEnumDriverInfo(hDevInfo, NULL, SPDIT_CLASSDRIVER, i, &sdr)

... yields no results.

So, how can I find the driver details that are mapped to device? If I can
find that, I can know if correct driver is used, if not, I can (re)install
the driver by using UpdateDriverForPlugAndPlayDevices API.

Thanks for your help.

Lisa




<chris.aseltine@gmail.com> wrote in message
news:89f22abe-2c1a-4b66-915e-646091616075@v3g2000hsc.googlegroups.com...
> On Mar 14, 5:38 pm, Lisa Pearlson <reag...@yahoo.com> wrote:
>
>> However, when I uninstall the device, the above still lists its device
>> id (because the driver is still present, I think). And I don't want
>> this.
>
> How are you "uninstalling" the device? Through Modem control panel or
> Device Manager? This API doesn't know about "installed drivers".
>
> The default is to show all devices, including unconnected devices.
> You will only see "present" devices only if you pass DIGCF_PRESENT.
>
> For each instance returned, you can call CM_Get_DevNode_Status() to
> see if the device is connected or not.



Re: Listing Unattached modems by chris

chris
Mon Mar 17 12:31:06 CDT 2008

On Mar 16, 1:41 pm, "Lisa Pearlson" <n...@spam.plz> wrote:

> So, how can I find the driver details that are mapped to device? If I can
> find that, I can know if correct driver is used, if not, I can (re)install
> the driver by using UpdateDriverForPlugAndPlayDevices API.

I would try to pull a few keys from the device's hardware node in the
registry (i.e. CCS\Enum\USB\Vid_xxxx&Pid_xxxx) that would only be
populated if a driver were loaded. For example: "Driver", "Service",
"Class", and so on.

Re: Listing Unattached modems by Doron

Doron
Mon Mar 17 13:28:45 CDT 2008

note that spelunking CCS\enum\... manually is not advised and is supposed to
be an opaque abstraction. the modem ui is certainly not walking this tree to
get the list of unattached modems. why not attach procmon to the UI and see
what reg keys and values it opens and queries for ?

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


<chris.aseltine@gmail.com> wrote in message
news:b3c8ee98-e476-40bc-b898-80b6a48761e1@n75g2000hsh.googlegroups.com...
> On Mar 16, 1:41 pm, "Lisa Pearlson" <n...@spam.plz> wrote:
>
>> So, how can I find the driver details that are mapped to device? If I can
>> find that, I can know if correct driver is used, if not, I can
>> (re)install
>> the driver by using UpdateDriverForPlugAndPlayDevices API.
>
> I would try to pull a few keys from the device's hardware node in the
> registry (i.e. CCS\Enum\USB\Vid_xxxx&Pid_xxxx) that would only be
> populated if a driver were loaded. For example: "Driver", "Service",
> "Class", and so on.


Re: Listing Unattached modems by chris

chris
Mon Mar 17 15:11:58 CDT 2008

On Mar 17, 1:28 pm, "Doron Holan [MSFT]" <dor...@online.microsoft.com>
wrote:

> note that spelunking CCS\enum\... manually is not advised and is supposed to
> be an opaque abstraction. the modem ui is certainly not walking this tree to
> get the list of unattached modems. why not attach procmon to the UI and see
> what reg keys and values it opens and queries for ?

Note that in case, you're taking me a little too literally. The
implementation of what I advised earlier would likely be a call to
SetupDiGetDeviceRegistryProperty() with argument SPDRP_DRIVER and so
on. I know that "spelunking" CCS\Enum is a no-no...

Re: Listing Unattached modems by Lisa

Lisa
Mon Mar 17 19:25:32 CDT 2008

I don't want to spelunk, and using API's to read registry keys, still might
defeat the abstraction, as the whole registry key itself I think is supposed
to be an abstraction.

Surely this isn't the way to get driver details?

I'd expect there's a way to walk through the devnodes, then once a devnode
is found, fetch the driver details, like manufacturer, description, driver
version and maybe wether device is attached or not..
But not sure how to walk non-attached devices, and which apis to use to get
the associated drivers.. Is reading this from registry (either directely or
using registry api's) really the way?

I'm not experienced with procmon, not even sure where I can find it. Don't
see it under my VS2005 tools in start menu, but I'm sure it doesn't reveil
proper APIs to use.

Thanks for your answers.

Lisa


<chris.aseltine@gmail.com> wrote in message
news:603244da-e221-45c5-9ae6-4e15af93564a@v3g2000hsc.googlegroups.com...
> On Mar 17, 1:28 pm, "Doron Holan [MSFT]" <dor...@online.microsoft.com>
> wrote:
>
>> note that spelunking CCS\enum\... manually is not advised and is supposed
>> to
>> be an opaque abstraction. the modem ui is certainly not walking this tree
>> to
>> get the list of unattached modems. why not attach procmon to the UI and
>> see
>> what reg keys and values it opens and queries for ?
>
> Note that in case, you're taking me a little too literally. The
> implementation of what I advised earlier would likely be a call to
> SetupDiGetDeviceRegistryProperty() with argument SPDRP_DRIVER and so
> on. I know that "spelunking" CCS\Enum is a no-no...



Re: Listing Unattached modems by chris

chris
Mon Mar 17 20:10:14 CDT 2008

On Mar 17, 7:25 pm, "Lisa Pearlson" <n...@spam.plz> wrote:

> I'd expect there's a way to walk through the devnodes, then once a devnode
> is found, fetch the driver details, like manufacturer, description, driver
> version and maybe wether device is attached or not..

Hello, there is, SetupDiGetDeviceRegistryProperty(). Did you even
read about that method?

It takes an HDEVINFO and SP_DEVINFO_DATA. You don't actually touch
any registry keys directly. Is that abstract enough for you?