diff --git a/ScreenRecorderLib/Recorder.cpp b/ScreenRecorderLib/Recorder.cpp index d9f4e81..a3699a6 100644 --- a/ScreenRecorderLib/Recorder.cpp +++ b/ScreenRecorderLib/Recorder.cpp @@ -560,10 +560,21 @@ List^ ScreenRecorderLib::Recorder::GetSupportedVideoCapture MeasureExecutionTime measure(L"GetSupportedVideoCaptureFormatsForDevice"); std::vector captureDevices; HRESULT hr = EnumVideoCaptureDevices(&captureDevices); + std::wstring devicePathWstring = msclr::interop::marshal_as(DevicePath); + + if (SUCCEEDED(hr)) { ReleaseVectorOnExit release(captureDevices); for (auto const& pDevice : captureDevices) { + // Get the device path + WCHAR* symbolicLink = NULL; + UINT32 cchSymbolicLink; + hr = pDevice->GetAllocatedString(MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, &symbolicLink, &cchSymbolicLink); + CoTaskMemFreeOnExit freeSymbolicLink(symbolicLink); + if (FAILED(hr) || symbolicLink == NULL || (!devicePathWstring.empty() && devicePathWstring != symbolicLink)) { + continue; + } CComPtr pSource = nullptr; CONTINUE_ON_BAD_HR(hr = pDevice->ActivateObject(__uuidof(IMFMediaSource), (void**)&pSource));