Skip to content

Commit 1d2e50d

Browse files
Read the vcam GUID from the install file (#1553)
* Read the vcam GUID from the install file * Formatting * Formatting Read the vcam GUID from the install file * Remove stray +
1 parent aaefe66 commit 1d2e50d

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

obs-studio-client/source/nodeobs_service.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
//#include <node.h>
2828
#include <sstream>
2929
#include <string>
30+
#include <fstream>
3031
#include "shared.hpp"
3132
#include "utility.hpp"
3233
#include "video.hpp"
@@ -489,20 +490,45 @@ Napi::Value service::OBS_service_isVirtualCamPluginInstalled(const Napi::Callbac
489490
HKEY OpenResult;
490491
LONG error;
491492

492-
error = RegOpenKeyEx(HKEY_CLASSES_ROOT, L"CLSID\\{27B05C2D-93DC-474A-A5DA-9BBA34CB2A9C}", 0, KEY_READ | KEY_WOW64_64KEY, &OpenResult);
493+
const char *prefix = "CLSID\\{";
494+
std::string line = "";
495+
std::string guid = "";
496+
size_t pos = 0;
497+
size_t endPos = 0;
498+
499+
//open install file and search for the correct GUID
500+
std::wstring batPath = utfWorkingDir + L"\\data\\obs-plugins\\win-dshow\\virtualcam-install.bat";
501+
std::ifstream batFile(batPath.c_str());
502+
if (batFile.is_open()) {
503+
while (std::getline(batFile, line)) {
504+
pos = line.find(prefix);
505+
if (pos != std::string::npos) {
506+
pos += strlen(prefix);
507+
endPos = line.find("}");
508+
guid = line.substr(pos, endPos - pos);
509+
guid.insert(0, prefix);
510+
guid.append("}");
511+
break;
512+
}
513+
}
514+
batFile.close();
515+
}
516+
517+
std::wstring wideGUID(from_utf8_to_utf16_wide(guid.c_str()));
518+
error = RegOpenKeyEx(HKEY_CLASSES_ROOT, wideGUID.c_str(), 0, KEY_READ | KEY_WOW64_64KEY, &OpenResult);
493519
if (error != ERROR_SUCCESS) {
494520
return Napi::Number::New(info.Env(), VcamInstalledStatus::NotInstalled);
495521
}
496522

497-
error = RegOpenKeyEx(HKEY_CLASSES_ROOT, L"CLSID\\{27B05C2D-93DC-474A-A5DA-9BBA34CB2A9C}", 0, KEY_READ | KEY_WOW64_32KEY, &OpenResult);
523+
error = RegOpenKeyEx(HKEY_CLASSES_ROOT, wideGUID.c_str(), 0, KEY_READ | KEY_WOW64_32KEY, &OpenResult);
498524
if (error != ERROR_SUCCESS) {
499525
return Napi::Number::New(info.Env(), VcamInstalledStatus::NotInstalled);
500526
}
501527

502528
DWORD dwRet = 0;
503529
TCHAR buf[TOTALBYTES] = {0};
504530
DWORD dwBufSize = sizeof(buf);
505-
error = RegOpenKeyEx(HKEY_CLASSES_ROOT, L"CLSID\\{27B05C2D-93DC-474A-A5DA-9BBA34CB2A9C}\\InprocServer32", 0, KEY_READ | KEY_QUERY_VALUE, &OpenResult);
531+
error = RegOpenKeyEx(HKEY_CLASSES_ROOT, wideGUID.c_str(), 0, KEY_READ | KEY_QUERY_VALUE, &OpenResult);
506532
if (error == ERROR_SUCCESS && OpenResult) {
507533
dwRet = RegQueryValueExW(OpenResult, TEXT(""), NULL, NULL, (LPBYTE)buf, &dwBufSize);
508534
if (dwRet == ERROR_SUCCESS) {

0 commit comments

Comments
 (0)