public static void SetDefaultEndpoint(string devId, ERole eRole)
        {
            _PolicyConfigClient policyConfig = null;

            try
            {
                policyConfig = new _PolicyConfigClient();

                var policyConfigX     = policyConfig as IPolicyConfigX;
                var policyConfig7     = policyConfig as IPolicyConfig;
                var policyConfigVista = policyConfig as IPolicyConfigVista;

                if (policyConfigX != null)
                {
                    Marshal.ThrowExceptionForHR(policyConfigX.SetDefaultEndpoint(devId, eRole));
                }
                else if (policyConfig7 != null)
                {
                    Marshal.ThrowExceptionForHR(policyConfig7.SetDefaultEndpoint(devId, eRole));
                }
                else if (policyConfigVista != null)
                {
                    Marshal.ThrowExceptionForHR(policyConfigVista.SetDefaultEndpoint(devId, eRole));
                }
            }
            finally
            {
                if (policyConfig != null && Marshal.IsComObject(policyConfig))
                {
                    Marshal.FinalReleaseComObject(policyConfig);
                }

                GC.Collect();
            }
        }
Exemple #2
0
        public static void SetDefaultEndpoint(string devId, ERole eRole)
        {
            _PolicyConfigClient policyConfig = null;
            try
            {
                policyConfig = new _PolicyConfigClient();

                var policyConfigX = policyConfig as IPolicyConfigX;
                var policyConfig7 = policyConfig as IPolicyConfig;
                var policyConfigVista = policyConfig as IPolicyConfigVista;

                if (policyConfigX != null)
                {
                    Marshal.ThrowExceptionForHR(policyConfigX.SetDefaultEndpoint(devId, eRole));
                }
                else if (policyConfig7 != null)
                {
                    Marshal.ThrowExceptionForHR(policyConfig7.SetDefaultEndpoint(devId, eRole));
                }
                else if (policyConfigVista != null)
                {
                    Marshal.ThrowExceptionForHR(policyConfigVista.SetDefaultEndpoint(devId, eRole));
                }
            }
            finally
            {
                if (policyConfig != null && Marshal.IsComObject(policyConfig))
                    Marshal.FinalReleaseComObject(policyConfig);

                GC.Collect();
            }
        }
Exemple #3
0
        public PolicyClient()
        {
            _policyConfig = new _PolicyConfigClient();

            _configX     = _policyConfig as IPolicyConfigX;
            _configVII   = _policyConfig as IPolicyConfig;
            _configVista = _policyConfig as IPolicyConfigVista;
        }
Exemple #4
0
        public static bool SwitchToPlaybackDevice(string devId)
        {
            var config = new _PolicyConfigClient() as IPolicyConfig;

            config.SetDefaultEndpoint(devId, ERole.Console);
            config.SetDefaultEndpoint(devId, ERole.Multimedia);
            config.SetDefaultEndpoint(devId, ERole.Communications);
            return(true);
        }
Exemple #5
0
        public static void SetDefaultEndpoint(string devId, ERole eRole)
        {
            IPolicyConfig policyConfig = null;

            try
            {
                // ReSharper disable once SuspiciousTypeConversion.Global
                policyConfig = new _PolicyConfigClient() as IPolicyConfig;
                if (policyConfig != null)
                {
                    Marshal.ThrowExceptionForHR(policyConfig.SetDefaultEndpoint(devId, eRole));
                }
            }
            finally
            {
                if (policyConfig != null && Marshal.IsComObject(policyConfig))
                {
                    Marshal.FinalReleaseComObject(policyConfig);
                }

                GC.Collect();
            }
        }
        //private readonly IPolicyConfig _PolicyConfig = new _PolicyConfigClient() as IPolicyConfig;

        public static void SetDefaultEndpoint(string devID, Role eRole)
        {
            var _PolicyConfig = new _PolicyConfigClient() as IPolicyConfig;

            Marshal.ThrowExceptionForHR(_PolicyConfig.SetDefaultEndpoint(devID, eRole));
        }
        //private readonly IPolicyConfig _PolicyConfig = new _PolicyConfigClient() as IPolicyConfig;

        public static void SetDefaultEndpoint(string devID, Role eRole)
        {
            var _PolicyConfig = new _PolicyConfigClient() as IPolicyConfig;
            Marshal.ThrowExceptionForHR(_PolicyConfig.SetDefaultEndpoint(devID, eRole));
        }