How to get a list of available resolutions for every camera on Windows C++

I have multiple cameras in my Windows 11 system and I am wondering how to get all avaiable resolutions for them. I am not intending to make a video capture, but I am willing to just get these properties.

Also, I don't care which API to use, be it DirectShow or MMF (Microsoft Media Foundation). I haven't used any of these before either.

I have found multiple resources doing that in C# (as in here), but similar suggested answers for C++ are hard to understand - some code is given, but what libraries and 'includes' used is not given (as in here)

I have also checked DirectShow samples in hope something would be there, but I didn't find anything.

So, I checked MMF as well (1, 2, 3) and docs, but all posts seem pretty outdated and no full code is given showing how to use certain functions alongside proper 'includes', as trying the code gives me unresolved symbols.

So I am kind of stuck at the moment, I can't find a solution to this.

I would appreciate any help.


Also, I don't care which API to use, be it DirectShow or MMF (Microsoft Media Foundation). I haven't used any of these before either.

You generally do care because the data might be different.

With Media Foundation, see How to Set the Video Capture Format

Call IMFMediaTypeHandler::GetMediaTypeCount to get the number of supported formats.

You might also want to have a look at Tanta: Windows Media Foundation Sample Projects and sample code there.

With DirectShow, see Webcamera supported video formats in addition to links you found; you will have to sort out includes and libraries through, among SDK samples AMCap does some one this and can be built from source without additional external libraries, from original code or from this fork adopted to most recent VS.