What are track index and format index?

Hi everyone,
I’m trying to make a dropdown menu populated with the possible resolution of a selected webcam, at the moment i’m stuck on some issues about track and the format index because using different number gives me completely different results (as obvious, but i don’t know what i’m really doing).
So, now i’m trying to understand what these number really refers to, but online i haven’t found any relevant information.
In the images below you can see what i’m doing at the moment, when i switch camera i trigger the building of “Risoluzionewebcam” combo box but it doesn’t behave as it should, i have two webcams, it gives me only one choice for one of the webcams (640x360) and a resolution of 0 for the second one.

I would be very glad if someone could explain what the track and the format index are, and check if someone has done a system that permits to swap between different resolutions of a webcam via combo box.