I have actually managed to do this by using the registry.
It is a little ad-hoc and dodgy sometimes, but it is the best (and easiest) solution I have come up with.
When you select a webcam in that dialogue a reference is kept in the registry. Notice that when you only use one webcam, the window will only show up once (when you connect the webcam for the first time) or never at all.
Take a look in your registry at LocalMachine\\SYSTEM\\CurrentControlSet\\Control\\MediaResources\\msvideo\\MSVideo.VFWWDM.
The 'changeSource' is a parameter in the Connect function in my webcam class. When you want to change the source, you can simply put that variable on true and reconnectCode://Get the ID for the webcam if (changeSource == false) DevicePath = LoadWebcamRegistry(); else DevicePath = ""; //In case of a new device (DevicePath == ""), ask user and save to registry //Clearing DevicePath causes DRIVER_CONNECT to show dialog and update registry SetWebcamRegistry(DevicePath); //Try to connect to driver if (window.SendMessage(WebcamLib.WM_CAP_DRIVER_CONNECT, IntPtr.Zero, IntPtr.Zero)) { DevicePath = GetWebcamRegistry(); SaveWebcamRegistry(DevicePath); } else { Disconnect(); }
I'll leave editing the registry to you![]()





Reply With Quote