forked from L-udo/Obs-VCam-Changer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
85 lines (67 loc) · 2.68 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// See https://aka.ms/new-console-template for more information
using System;
using Microsoft.Win32;
using System.Security.Principal;
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WindowHeight = 10;
Console.WindowWidth = 50;
bool isElevated;
using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
{
WindowsPrincipal principal = new WindowsPrincipal(identity);
isElevated = principal.IsInRole(WindowsBuiltInRole.Administrator);
}
if (isElevated == false)
{
Console.WriteLine("You need to run this as Administrator!");
Console.WriteLine("Press Any Key to Exit");
Console.ReadLine();
System.Environment.Exit(0);
}
if (Registry.LocalMachine.OpenSubKey(@"SOFTWARE\OBS Studio").GetValue("") == null)
{
Console.WriteLine("ERR- No Obs Found! -- Do you have the Latest Obs Studio installed?");
Console.ReadLine();
System.Environment.Exit(0);
}
string[] cameras = {
@"SOFTWARE\Classes\CLSID\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\Instance\{A3FCE0F5-3493-419F-958A-ABA1250EC20B}",
@"SOFTWARE\Classes\CLSID\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\Instance\{27B05C2D-93DC-474A-A5DA-9BBA34CB2A9C}",
@"SOFTWARE\Classes\CLSID\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\Instance\{27B05C2D-93DC-474A-A5DA-9BBA34CB2A9D}",
@"SOFTWARE\Classes\CLSID\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\Instance\{27B05C2D-93DC-474A-A5DA-9BBA34CB2A9E}",
@"SOFTWARE\Classes\CLSID\{860BB310-5D01-11d0-BD3B-00A0C911CE86}\Instance\{27B05C2D-93DC-474A-A5DA-9BBA34CB2A9F}"
};
static int GetCams(string[] cameras) {
int ac = 0;
foreach (string cam in cameras)
{
RegistryKey camaddr = Registry.LocalMachine.OpenSubKey(cam, true);
if (camaddr == null) { Console.WriteLine("ERR-- Camera Not found"); }
else
{
Console.WriteLine($"Camera {ac} : " + camaddr.GetValue("FriendlyName"));
ac++;
}
}
return cameras.Length;
}
while (true) {
GetCams(cameras);
Console.WriteLine("\n");
Console.Write("What Camera name do you want to change?:");
int Cam2chng = Convert.ToUInt16(Console.ReadLine());
Console.Clear();
Console.WriteLine("Input new camera name:");
string CamName = Console.ReadLine();
Console.Clear();
RegistryKey key = Registry.LocalMachine.OpenSubKey(cameras[Cam2chng], true);
Console.Write("Original Camera Name: ");
Console.Write(key.GetValue("FriendlyName"));
key.SetValue("FriendlyName", CamName);
Console.WriteLine("\n");
Console.Write("New name Set to:");
Console.Write(key.GetValue("FriendlyName"));
Console.WriteLine("\n");
key.Close();
Console.Clear();
}