Beispiel #1
0
        /// <summary>
        /// Adds additional info to the registry to allow the shell to discover the oject as shell extension.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="description">The description.</param>
        protected static void ComRegister(Type type, string description)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            // Only register when supported by Shell.
            // Vista and up don't support column providers anymore (replaces by property system).
            if (IsShell60OrHigher())
            {
                return;
            }

            RegistryExtensions.AddAsApprovedShellExtension(type, description);

            // Register the COM object as a ColumnProvider handler.
            var subKeyName = ColumnHandlersKeyName + @"\" + type.GUID.ToString("B");

            using (var key = Registry.ClassesRoot.CreateSubKey(subKeyName))
            {
                if (key == null)
                {
                    throw new ApplicationException("Failed to create sub key: " + subKeyName);
                }

                key.SetValue(string.Empty, description);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Adds additional info to the registry to allow the shell to discover the oject as shell extension.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="description">The description.</param>
        /// <param name="progId">The prog id.</param>
        protected static void ComRegister(Type type, string description, string progId)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }
            if (description == progId)
            {
                throw new ArgumentNullException(nameof(progId));
            }

            RegistryExtensions.AddAsApprovedShellExtension(type, description);

            // Register the InfoTip COM object as the InfoTip handler. Only 1 handler can be installed for a file type.
            var subKeyName = progId + @"\ShellEx\{00021500-0000-0000-C000-000000000046}";

            using (var key = Registry.ClassesRoot.CreateSubKey(subKeyName))
            {
                if (key == null)
                {
                    throw new ApplicationException("Failed to create registry key: " + subKeyName);
                }

                key.SetValue(string.Empty, type.GUID.ToString("B"));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Adds additional info to the registry to allow the shell to discover the oject as shell extension.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="description">The description.</param>
        /// <param name="progId">The prog id.</param>
        protected static void ComRegister(Type type, string description, string progId)
        {
            Contract.Requires(type != null);
            Contract.Requires(!string.IsNullOrEmpty(description));
            Contract.Requires(!string.IsNullOrEmpty(progId));

            RegistryExtensions.AddAsApprovedShellExtension(type, description);

            // Register the InfoTip COM object as the InfoTip handler. Only 1 handler can be installed for a file type.
            //var subKeyName = progId + @"\ShellEx\{00021500-0000-0000-C000-000000000046}";
            //using (var key = Registry.ClassesRoot.CreateSubKey(subKeyName))
            //{
            //    if (key == null)
            //        throw new ApplicationException("Failed to create registry key: " + subKeyName);

            //    key.SetValue(string.Empty, type.GUID.ToString("B"));
            //}
        }
Beispiel #4
0
        /// <summary>
        /// Adds additional info to the registry to allow the shell to discover the oject as shell extension.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="description">The description.</param>
        /// <param name="progId">The prog id.</param>
        protected static void ComRegister(Type type, string description, string progId)
        {
            Contract.Requires(type != null);
            Contract.Requires(!string.IsNullOrEmpty(description));
            Contract.Requires(!string.IsNullOrEmpty(progId));

            RegistryExtensions.AddAsApprovedShellExtension(type, description);

            // Register the object as a property sheet handler.
            var subKeyName = progId + @"\ShellEx\PropertySheetHandlers\" + description;

            using (var key = Registry.ClassesRoot.CreateSubKey(subKeyName))
            {
                if (key == null)
                {
                    throw new ApplicationException("Failed to create sub key: " + subKeyName);
                }

                key.SetValue(string.Empty, type.GUID.ToString("B"));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Adds additional info to the registry to allow the shell to discover the oject as shell extension.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="name">The name.</param>
        /// <param name="description">The description.</param>
        protected static void ComRegister(Type type, string name, string description)
        {
            Contract.Requires(type != null);
            Contract.Requires(!string.IsNullOrEmpty(name));
            Contract.Requires(!string.IsNullOrEmpty(description));

            RegistryExtensions.AddAsApprovedShellExtension(type, description);

            // Register the CopyHook COM object as a copy hook handler.
            var keyName = @"Directory\ShellEx\CopyHookHandlers\" + name;

            using (var key = Registry.ClassesRoot.CreateSubKey(keyName))
            {
                if (key == null)
                {
                    throw new ApplicationException("Failed to open registry key: " + keyName);
                }

                key.SetValue(string.Empty, type.GUID.ToString("B"));
            }
        }
Beispiel #6
0
        /// <summary>
        /// Adds additional info to the registry to allow the shell to discover the oject as shell extension.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="description">The description.</param>
        /// <param name="progId">The prog id.</param>
        protected static void ComRegister(Type type, string description, string progId)
        {
            if (progId == null)
            {
                throw new ArgumentNullException(nameof(progId));
            }

            RegistryExtensions.AddAsApprovedShellExtension(type, description);

            // Register the ContextMenu COM object as the ContextMenu handler.
            var subKeyName = progId + @"\ShellEx\ContextMenuHandlers\" + description;

            using (var key = Registry.ClassesRoot.CreateSubKey(subKeyName))
            {
                if (key == null)
                {
                    throw new ApplicationException("Failed to create sub key: " + subKeyName);
                }

                key.SetValue(string.Empty, type.GUID.ToString("B"));
            }
        }