简体   繁体   中英

Can't get a reference to IPart

I'm trying to get a reference to the IPart interface to control Windows audio volume level, for example, and I'm using the IDeviceTopology::GetPartById function to get it.

This function takes a UINT. I tried 0 and got nothing, then gave in and just tried incrementing a UINT until I could get a reference. No luck that way.

I've got a reference to the correct device topology.

My HRESULT is E_INVALIDARG .

Is it just the case that there aren't any parts available on my device?

MSDN says to get an ID to pass into GetPartById, I should call IAudioInputSelector::GetSelection . To use IAudioInputSelector though, I need to already have a reference to an IPart object.

The easiest way is to enumerate the host pins and call GetSignalPath from the desired input to the desired output, that will return you a collection of parts.

Alternatively, if you have a topology object, you can call GetSubunit or GetConnector to retrieve the subunits or connectors (which are also parts). From each connector, you can call GetConnectedTo() which will return the part on the other side of the connector. Continue and you'll be able to walk the entire topology graph and identify all the parts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM