Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is more of a question about the issue. When you call the function the first arg you pass in should be DeviceInfoSet which you likely got from the <a href="http://msdn.microsoft.com/en-us/library/ms792959.aspx" rel="nofollow noreferrer">SetupDiGetClassDevs</a> function. When you called the SetupDiGetClassDevs function what did you specify for the flags (Last Argument) Quoting Microsoft's Page on the function:</p> <blockquote> <p><strong>DIGCF_ALLCLASSES</strong> Return a list of installed devices for all device setup classes or all device interface classes. </p> <p><strong>DIGCF_DEVICEINTERFACE</strong> Return devices that support device interfaces for the specified device interface classes. This flag must be set in the Flags parameter if the Enumerator parameter specifies a device instance ID. </p> <p><strong>DIGCF_DEFAULT</strong> Return only the device that is associated with the system default device interface, if one is set, for the specified device interface classes. </p> <p><strong>DIGCF_PRESENT</strong> Return only devices that are currently present in a system. </p> <p><strong>DIGCF_PROFILE</strong> Return only devices that are a part of the current hardware profile.</p> </blockquote> <p>Depending on your choice the list of devices changes. For example The Present flag will only show devices plugged in actively. </p> <hr> <p>UPDATE: Thanks for the sample code.</p> <p>My question now, is if you want to know the friendly name of the modem why not use the same call but specify the Modem Guid instead of the COM Port? I have the Modem GUID being 4D36E96D-E325-11CE-BFC1-08002BE10318</p> <p>In the registry I can see a value called 'AttachedTo' which specifies a COM Port. I'll have to research which property thats is tied to in the API. The registry key is at</p> <p>HKLM\SYSTEM\CurrentControlSet\Control\Class{4D36E96D-E325-11CE-BFC1-08002BE10318}\</p> <hr> <p>ANOTHER UPDATE:</p> <p>Looking closer at the sample code. Based on this, if you are trying to get the device interface class that should return a <a href="http://msdn.microsoft.com/en-us/library/ms793116.aspx" rel="nofollow noreferrer">SP_DEVICE_INTERFACE_DETAIL_DATA</a> Structure. That wouldn't provide a way of getting the friendly name of the device. I believe instead you would want the device instance. </p> <p>From what I've read, the Device Interface is used to as a way to get the device path which can be used to write to it.</p> <p>One thing I did to test your code was try it again the Disk Device Interface. I made a few changes to get it to work on my system and it still isn't quite done. I think the one problem (probably more) is that I need to resize the DevicePath variable inbetween the SetupDiGetDeviceInterfaceDetail calls.</p> <pre><code>void Test() { GUID *serial_port_guid = const_cast&lt;GUID *&gt;(&amp;GUID_DEVINTERFACE_DISK); HDEVINFO device_info = INVALID_HANDLE_VALUE; SP_DEVICE_INTERFACE_DETAIL_DATA detail_data; device_info = SetupDiGetClassDevs( serial_port_guid, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if(device_info != INVALID_HANDLE_VALUE) { //uint4 const detail_data_size = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);// + 256; //detail_data = reinterpret_cast&lt;SP_DEVICE_INTERFACE_DETAIL_DATA *&gt;(new char[detail_data_size]); SP_DEVICE_INTERFACE_DATA ifc_data; bool more_interfaces = true; int rcd; memset(&amp;ifc_data, 0, sizeof(ifc_data)); //memset(detail_data, 0, detail_data_size); ifc_data.cbSize = sizeof(ifc_data); detail_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); for(uint4 index = 0; more_interfaces; ++index) { rcd = SetupDiEnumDeviceInterfaces(device_info, 0, serial_port_guid, index, &amp;ifc_data); if(rcd) { // we need to get the details of this device SP_DEVINFO_DATA device_data; device_data.cbSize = sizeof(SP_DEVINFO_DATA); DWORD intReqSize; rcd = SetupDiGetDeviceInterfaceDetail(device_info, &amp;ifc_data, 0, 0, &amp;intReqSize, &amp;device_data); rcd = SetupDiGetDeviceInterfaceDetail(device_info, &amp;ifc_data, &amp;detail_data,intReqSize,&amp;intReqSize,&amp;device_data); if(rcd) { //StrAsc device_path(detail_data-&gt;DevicePath); byte friendly_name[256]; rcd = SetupDiGetDeviceRegistryProperty( device_info, &amp;device_data, SPDRP_FRIENDLYNAME, 0, friendly_name, sizeof(friendly_name), reinterpret_cast&lt;DWORD *&gt;(sizeof(friendly_name))); if(rcd) { cout&lt;&lt;reinterpret_cast&lt;char const *&gt;(friendly_name); } else { int num = GetLastError(); } } else { int num = GetLastError(); } } else more_interfaces = false; } } SetupDiDestroyDeviceInfoList(device_info); } </code></pre> <p>Also, in the INF, you may have to add the <a href="http://msdn.microsoft.com/en-us/library/ms794355.aspx" rel="nofollow noreferrer">AddInterface</a> directive to associate your driver with the correct interface. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload