forked from konnogatto/SwitchDisplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PolicyConfigClient.cs
52 lines (47 loc) · 1.72 KB
/
PolicyConfigClient.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
using System;
using System.Runtime.InteropServices;
using NAudio.CoreAudioApi;
using SwitchDisplay.Interfaces;
namespace SwitchDisplay
{
class PolicyConfigClient
{
public void SetDefaultEndpoint(string devID, Role role)
{
object policyConfig = null;
try
{
policyConfig = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(InterfaceIds.POLICY_CONFIG_CID)));
switch (policyConfig)
{
case IPolicyConfigRS3 config:
config.SetDefaultEndpoint(devID, role);
break;
case IPolicyConfigRS2 config:
config.SetDefaultEndpoint(devID, role);
break;
case IPolicyConfigRS config:
config.SetDefaultEndpoint(devID, role);
break;
case IPolicyConfig10 config:
config.SetDefaultEndpoint(devID, role);
break;
case IPolicyConfig config:
config.SetDefaultEndpoint(devID, role);
break;
case IPolicyConfigVista config:
config.SetDefaultEndpoint(devID, role);
break;
case IPolicyConfigUnknown config:
config.SetDefaultEndpoint(devID, role);
break;
}
}
finally
{
if (policyConfig != null && Marshal.IsComObject(policyConfig))
Marshal.FinalReleaseComObject(policyConfig);
}
}
}
}