Unable to set friendly name for device in Windows 7

In my UMDF device driver, I configured a friendly name for my device:

HRESULT CMyDevice::SetFriendlyDeviceName(WCHAR * FriendlyName)
{
    HRESULT hr = HRESULT_FROM_WIN32(ERROR_GEN_FAILURE);
    CComPtr<IWDFUnifiedPropertyStoreFactory> upsf = NULL;

    hr = m_FxDevice->QueryInterface(&upsf);
    if (SUCCEEDED(hr))
    {
        CComPtr<IWDFUnifiedPropertyStore> ups = NULL;
        WDF_PROPERTY_STORE_ROOT rs;

        RtlZeroMemory(&rs, sizeof(WDF_PROPERTY_STORE_ROOT));
        rs.LengthCb = sizeof(WDF_PROPERTY_STORE_ROOT);
        rs.RootClass = WdfPropertyStoreRootClassHardwareKey;
        rs.Qualifier.HardwareKey.ServiceName = NULL;

        hr = upsf->RetrieveUnifiedDevicePropertyStore(&rs, &ups);
        if (SUCCEEDED(hr))
        {
            ULONG len = ((ULONG)wcslen(FriendlyName) * sizeof(WCHAR)) + sizeof(WCHAR);

            hr = ups->SetPropertyData(&DEVPKEY_Device_FriendlyName, 0, 0, DEVPROP_TYPE_STRING, len, FriendlyName);
            if (FAILED(hr))
                TraceEvents(TRACE_LEVEL_WARNING, TRACE_DEVICE, "Failed to set friendly name for device: %x", hr);
            else
                TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DEVICE, "Friendly name for device successfully set");
        }
        else
            TraceEvents(TRACE_LEVEL_WARNING, TRACE_DEVICE, "Failed to retrieve unified device property store: %x", hr);
    }
    else
        TraceEvents(TRACE_LEVEL_WARNING, TRACE_DEVICE, "Failed to retrieve unified property store factory: %x", hr);

}

      

It works in Windows 8 and 10. The problem is, it doesn't work in Windows 7 and Vista. Although I don't see any errors running the code above and it says "Friendly name for the device has been successfully set", the friendly name does not change in Device Manager. It also does not change after updating the device list. When I look into my device's storage key in the registry HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_XXXX&PID_XXXX\XXXX

, there is no value for "FriendlyName". When I add it manually, it shows up in the device manager.

+3
windows driver wdf umdf


source to share


No one has answered this question yet

Check out similar questions:

2453
How do I install pip on Windows?
2195
Is there an equivalent to "which" on the Windows command line?
1975
How do I know which process is listening on a port on Windows?
1141
How can I develop for iPhone using Windows development machine?
973
Ignoring directories in Git repos on Windows
951
Node.js / Windows Error: ENOENT, stat 'C: \ Users \ RT \ AppData \ Roaming \ npm'
766
How do I run two commands on the same line in Windows CMD?
706
Windows batch files: .bat vs .cmd?
539
Setting Windows PowerShell Environment Variables
452
How do I set up an editor to work with Git on Windows?



All Articles
Loading...
X
Show
Funny
Dev
Pics