|
27 | 27 | //#include <node.h>
|
28 | 28 | #include <sstream>
|
29 | 29 | #include <string>
|
| 30 | +#include <fstream> |
30 | 31 | #include "shared.hpp"
|
31 | 32 | #include "utility.hpp"
|
32 | 33 | #include "video.hpp"
|
@@ -489,20 +490,45 @@ Napi::Value service::OBS_service_isVirtualCamPluginInstalled(const Napi::Callbac
|
489 | 490 | HKEY OpenResult;
|
490 | 491 | LONG error;
|
491 | 492 |
|
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); |
493 | 519 | if (error != ERROR_SUCCESS) {
|
494 | 520 | return Napi::Number::New(info.Env(), VcamInstalledStatus::NotInstalled);
|
495 | 521 | }
|
496 | 522 |
|
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); |
498 | 524 | if (error != ERROR_SUCCESS) {
|
499 | 525 | return Napi::Number::New(info.Env(), VcamInstalledStatus::NotInstalled);
|
500 | 526 | }
|
501 | 527 |
|
502 | 528 | DWORD dwRet = 0;
|
503 | 529 | TCHAR buf[TOTALBYTES] = {0};
|
504 | 530 | 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); |
506 | 532 | if (error == ERROR_SUCCESS && OpenResult) {
|
507 | 533 | dwRet = RegQueryValueExW(OpenResult, TEXT(""), NULL, NULL, (LPBYTE)buf, &dwBufSize);
|
508 | 534 | if (dwRet == ERROR_SUCCESS) {
|
|
0 commit comments