I'm making a C++/winRT GUI application that uses the IMFVirtualCamera interface from Microsoft Media Foundation to create a virtual camera device.
Virtual camera creation:
winrt::check_hresult(MFCreateVirtualCamera(
MFVirtualCameraType_SoftwareCameraSource,
MFVirtualCameraLifetime_Session,
MFVirtualCameraAccess_AllUsers,
cameraName,
L"{7B89B92E-FE71-42D0-8A41-E137D06EA184}",
nullptr,
0,
pVirtualCamera.put()
));
Code for starting the virtual camera:
try {
winrt::check_hresult(pVirtualCamera->Start(nullptr));
}
catch (winrt::hresult_error const& ex)
{
std::stringstream ss;
ss << winrt::to_string(ex.message()) << " - " << ex.code();
LOG(LogLevel::ERR, ss.str());
}
The Start() function actually throws an error stating "Access is denied"
. I've tried running Visual Studio as administrator and also set the UAC Execution Level
in Properties > Linker > Manifest File
to requireAdministrator
. The problem still persists.
As pointed in the comments by Simon, switching the access
parameter in the MFCreateVirtualCamera
function to MFVirtualCameraAccess_CurrentUser
solves the "Access is denied" error as lower privileges are required for the same.