none
Read from registry Error (UMDF) RRS feed

  • Question

  • Hi All:

          I found I use the follow way to read registry will result in error 0x80070002 by GetNameValue method. And I can't find this error code from winerror.h file. Did I have any wrong when I read the registry?

         My code:
     hr = m_FxDevice->QueryInterface(IID_PPV_ARGS(&pPropertyStoreFactory));
    
        if (FAILED(hr))
        {
            Trace(
                TRACE_LEVEL_ERROR,
                L"ERROR: QI for IWDFPropertyStoreFactory failed"
                );
    
            goto Exit;
        }
    
        RootSpecifier.LengthCb = sizeof(WDF_PROPERTY_STORE_ROOT);
        RootSpecifier.RootClass = WdfPropertyStoreRootClassHardwareKey;
        RootSpecifier.Qualifier.HardwareKey.ServiceName =
    		WDF_PROPERTY_STORE_HARDWARE_KEY_DEFAULT;//WDF_PROPERTY_STORE_HARDWARE_KEY_ROOT;
    
        hr = pPropertyStoreFactory->RetrieveDevicePropertyStore(
                                               &RootSpecifier,
                                               WdfPropertyStoreCreateIfMissing,//WdfPropertyStoreNormal,
    										   KEY_READ,//KEY_QUERY_VALUE,
                                               NULL,
                                               &pHardwarePropertyStore,
                                               NULL
                                               );
    
        if (FAILED(hr))
        {
            Trace(
                TRACE_LEVEL_ERROR,
                L"ERROR: Failed to retrieve device hardware key root"
                );
            goto Exit;
        }
    
        hr = pHardwarePropertyStore->GetNamedValue(L"portName", &comPortPV);
    
        if (FAILED(hr))
        {
            Trace(
                TRACE_LEVEL_ERROR,
                L"ERROR: Failed to read value %ws",
                portName
                );
            goto Exit;
        }

    Tuesday, December 11, 2012 3:31 AM

Answers

  • Hi,

    Does the "portName" value exist?

    Please check HKLM\SYSTEM\CurrentControlSet\Enum\<enumerator>\<class>\<instance>\Device Parameters\<driver service name>. If it's not there, try to set it programmatically or via your INF file - http://msdn.microsoft.com/en-us/library/windows/hardware/ff547330(v=vs.85).aspx

    If you set it via the INF file, make sure you either specify the driver's service name as the subkey to the AddReg directive, or you leave the subkey blank and change your code above back to WDF_PROPERTY_STORE_HARDWARE_KEY_ROOT and WdfPropertyStoreNormal.

    Please let us know if you have any problems.

    Tuesday, December 11, 2012 5:55 PM

All replies

  • Hi,

    Does the "portName" value exist?

    Please check HKLM\SYSTEM\CurrentControlSet\Enum\<enumerator>\<class>\<instance>\Device Parameters\<driver service name>. If it's not there, try to set it programmatically or via your INF file - http://msdn.microsoft.com/en-us/library/windows/hardware/ff547330(v=vs.85).aspx

    If you set it via the INF file, make sure you either specify the driver's service name as the subkey to the AddReg directive, or you leave the subkey blank and change your code above back to WDF_PROPERTY_STORE_HARDWARE_KEY_ROOT and WdfPropertyStoreNormal.

    Please let us know if you have any problems.

    Tuesday, December 11, 2012 5:55 PM
  • Thank you for your reply.

    I think I can use inf file to set value for the device.

    THX.

    Wednesday, December 12, 2012 9:30 AM