0

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.

Ciaran
  • 1,878
  • 5
  • 18
  • 31
  • "learn by doing and googling approach" You'll never learn, then. There is an extraordinary amount of bad C++, unidiomatic C++, and simply incorrect C++ information online that you'll just end up becoming a mess. You have to get a [book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list), then another one, and maybe another one and another one. – GManNickG Feb 05 '11 at 23:29
  • Let me rephrase then; I want to use C++ to carry out a task. I assume MSDN is a reputable source for sample code. If I wanted advice on learning the language itself I would have asked or looked at the many questions that have already been asked about it. – Ciaran Feb 05 '11 at 23:34
  • Then remove the last bit of information from your question if you don't want it to be commented on. – GManNickG Feb 05 '11 at 23:39
  • It was there as more of a "go easy on me if I'm doing something stupid" touch than "I want to know everything about C++" touch but I removed it. Thanks for the advice. – Ciaran Feb 05 '11 at 23:45
  • 1
    Is there a reason you're using device topology to control the volume instead of the volume APIs? – Larry Osterman Feb 06 '11 at 08:05

1 Answers1

1

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.

Larry Osterman
  • 16,086
  • 32
  • 60