简体   繁体   English

无法获得对IPart的引用

[英]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. 例如,我试图获取对IPart接口的引用以控制Windows音频音量,并且我正在使用IDeviceTopology::GetPartById函数来获取它。

This function takes a UINT. 此功能需要一个UINT。 I tried 0 and got nothing, then gave in and just tried incrementing a UINT until I could get a reference. 我尝试了0却一无所获,然后屈服了,只是尝试增加UINT直到获得参考为止。 No luck that way. 那样没有运气。

I've got a reference to the correct device topology. 我已经参考了正确的设备拓扑。

My HRESULT is E_INVALIDARG . 我的HRESULT是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 . MSDN说要获取传递给GetPartById的ID,我应该调用IAudioInputSelector::GetSelection To use IAudioInputSelector though, I need to already have a reference to an IPart object. 但是,要使用IAudioInputSelector,我需要已经有一个对IPart对象的引用。

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. 最简单的方法是枚举主机引脚,并从所需的输入调用GetSignalPath到所需的输出,这将返回一部分零件。

Alternatively, if you have a topology object, you can call GetSubunit or GetConnector to retrieve the subunits or connectors (which are also parts). 或者,如果您具有拓扑对象,则可以调用GetSubunit或GetConnector来检索子单元或连接器(它们也是零件)。 From each connector, you can call GetConnectedTo() which will return the part on the other side of the connector. 从每个连接器,您可以调用GetConnectedTo(),它将返回连接器另一侧的零件。 Continue and you'll be able to walk the entire topology graph and identify all the parts. 继续,您将可以遍历整个拓扑图并标识所有部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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