public void DoTests()
        {
            m_isbc = GetConfigure();

            try
            {
                TestBackingFileCount();
                TestDirectory();
                TestDuration();
            }
            finally
            {
                Marshal.ReleaseComObject(m_isbc);
            }
        }
        protected void ConfigureTimeShiftingRegistry()
        {
            //http://msdn.microsoft.com/en-us/library/windows/desktop/dd694948%28v=vs.85%29.aspx

            UIntPtr HKEY_CURRENT_USER = (UIntPtr)0x80000001;
            //unchecked
            //{
            //    HKEY_CURRENT_USER = (UIntPtr)0x80000001;
            //}

            // Create the StreamBufferConfig object.
            StreamBufferConfig     streamBufferConfig    = new StreamBufferConfig();
            IStreamBufferConfigure streamBufferConfigure = streamBufferConfig as IStreamBufferConfigure;

            // Create a new registry key to hold our settings.
            streamBufferConfigHKey = IntPtr.Zero;
            IntPtr p = Marshal.AllocCoTaskMem(4);

            Marshal.WriteIntPtr(p, IntPtr.Zero);
            try
            {
                int lRes = RegCreateKey(HKEY_CURRENT_USER, MainForm.RegistryBaseKey + "\\SBE", p);
                streamBufferConfigHKey = Marshal.ReadIntPtr(p);
            }
            finally
            {
                Marshal.FreeCoTaskMem(p);
            }

            // Set the registry key.
            IStreamBufferInitialize streamBufferInitialize = streamBufferConfigure as IStreamBufferInitialize;
            int hr = streamBufferInitialize.SetHKEY(streamBufferConfigHKey);

            DsError.ThrowExceptionForHR(hr);

            //http://msdn.microsoft.com/en-us/library/windows/desktop/dd694977%28v=vs.85%29.aspx
            //For Windows Vista or later the IStreamBufferSink::LockProfile method requires administrator privileges,
            // unless you first call IStreamBufferConfigure3::SetNamespace with the value NULL.
            IStreamBufferConfigure3 streamBufferConfigure3 = streamBufferConfig as IStreamBufferConfigure3;

            if (streamBufferConfigure3 != null)
            {
                hr = streamBufferConfigure3.SetNamespace(null);
                DsError.ThrowExceptionForHR(hr);
            }

            // Set the TimeShifting configuration
            //hr = streamBufferConfigure.SetDirectory("C:\\MyDirectory");
            string directory     = Settings.VideosFolder;
            string directoryPath = FileUtils.GetAbsolutePath(directory as string);

            hr = streamBufferConfigure.SetDirectory(directoryPath);
            DsError.ThrowExceptionForHR(hr);


            hr = streamBufferConfigure.SetBackingFileDuration(600);             // Min 15 seconds
            //TODO not working anymore!!
            hr = streamBufferConfigure.SetBackingFileCount(
                Math.Min(100, Math.Max(4, Settings.TimeShiftingBufferLengthMin / 10)),  // 4-100
                Math.Min(102, Math.Max(6, Settings.TimeShiftingBufferLengthMax / 10))); // 6-102
        }