From 5fa71724d41ceec5357a5d22785747b8daa93381 Mon Sep 17 00:00:00 2001 From: Tai Date: Sun, 24 Dec 2017 00:36:39 +0800 Subject: [PATCH] add dummy devicepath --- src/virtual-source/dllmain.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/virtual-source/dllmain.cpp b/src/virtual-source/dllmain.cpp index dc12182..51ac4eb 100644 --- a/src/virtual-source/dllmain.cpp +++ b/src/virtual-source/dllmain.cpp @@ -99,6 +99,37 @@ CFactoryTemplate g_Templates[] = int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]); +void RegisterDummyDevicePath() +{ + HKEY hKey; + std::string str_video_capture_device_key( + "SOFTWARE\\Classes\\CLSID\\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\\Instance\\"); + + LPOLESTR olestr_CLSID; + StringFromCLSID(CLSID_OBS_VirtualV, &olestr_CLSID); + + std::wstring wstr_CLSID(olestr_CLSID); + + int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr_CLSID[0], + (int)wstr_CLSID.size(), NULL, 0, NULL, NULL); + std::string str2(size_needed, 0); + WideCharToMultiByte(CP_UTF8, 0, &wstr_CLSID[0], (int)wstr_CLSID.size(), + &str2[0], size_needed, NULL, NULL); + + str_video_capture_device_key.append(str2); + + RegOpenKeyEx(HKEY_LOCAL_MACHINE, str_video_capture_device_key.c_str(), 0, + KEY_ALL_ACCESS, &hKey); + + + LPCTSTR value = TEXT("DevicePath"); + LPCTSTR data = "obs:virtualcam"; + if (ERROR_SUCCESS == RegSetValueEx(hKey, value, 0, REG_SZ, (LPBYTE)data, strlen(data) + 1)) + ::MessageBoxA(0, "ok", "ok", MB_OK); + + RegCloseKey(hKey); +} + STDAPI RegisterFilters(BOOL bRegister) { HRESULT hr = NOERROR; @@ -145,6 +176,9 @@ STDAPI RegisterFilters(BOOL bRegister) } } + if (SUCCEEDED(hr) && bRegister) + RegisterDummyDevicePath(); + if (fm) fm->Release(); }