IDSFDevice::Parent Property

The Parent property gets or sets the parent device for a device. This property is typically used by buses for attached devices.

This property is read/write.

Syntax

HRESULT put_Parent(
  [in]           DSFDevice *pDSFDevice
);

HRESULT get_Parent(
  [out, retval]  DSFDevice **ppDSFDevice
);

Property Value

The interface pointer to the parent device.

Error Codes

Parent returns one of the following values:

Name Meaning
S_OK

The operation succeeded.

E_POINTER

The ppDSFDevice parameter was not a valid pointer.

E_NOINTERFACE

The pDSFDevice parameter is not a valid DSFDevice object.

Examples

The following C++ example code shows how to get the Parent property so that the new device can be added to the parents children collection.

HRESULT CTestDevice:: AddDevice()
{
HRESULT              hr = S_OK;
IDSFDevice          *piDSFDevice = NULL; 
IDSFDevices        *piDSFDevices = NULL; 
IDSFDevice          *piParentDevice = NULL;

// Get the DSFDevice object
hr = m_piUSBDevice->get_DSFDevice(reinterpret_cast<DSFDevice**>(&piDSFDevice)); 
if (!FAILED(hr))
{  
  // Get the parent device 
 hr = piDSFDevice->get_Parent(reinterpret_cast<DSFDevice**>(&piParentDevice));
}

if(!FAILED(hr))
{ 
  // Get the children collection
 hr = piParentDevice->get_Children(&piDSFDevices);
 
 if(!FAILED(hr))
  {
 // Add this device to the children collection
 hr = piDSFDevice->Add(reinterpret_cast<DSFDevice*>(piDSFDevice));
  }
}


if (NULL != piDSFDevice)
{
piDSFDevice->Release();
piDSFDevice = NULL;   
}

if(NULL != piDSFDevices)
{     
piDSFDevices->Release();     
piDSFDevices = NULL;
}
 if(NULL != piParentDevice)
  {
 piParentDevice->Release();
 piParentDevice  = NULL;
}

return hr;
}

Requirements

Header

DSFif.h

See Also

IDSFDevice

 

 

Send comments about this topic to Microsoft

Build date: 9/21/2010