コード例 #1
0
        /// <summary>
        /// Harvest the registry values written by calling DllRegisterServer on the specified file.
        /// </summary>
        /// <param name="file">The file to harvest registry values from.</param>
        /// <param name="addShellExtensionKey">true to add shell extension key to registry before harvesting</param>
        /// <returns>The harvested registry values.</returns>
        public Wix.RegistryValue[] HarvestRegistryValues(string file, bool addShellExtensionKey)
        {
            this.isFile64Bit = Is64Bit(file);

            // load the DLL if 32-bit.
            if (!isFile64Bit)
            {
                NativeMethods.LoadLibrary(file);
            }

            using (var registryHarvester = new ATLRegistryHarvester(true, addShellExtensionKey))
            {
                try
                {
                    if (isFile64Bit)
                    {
                        StartProxyProcess64(file);
                    }
                    else
                    {
                        DynamicPInvoke(file, "DllRegisterServer", typeof(int), null, null);
                    }

                    return(registryHarvester.HarvestRegistry());
                }
                catch (TargetInvocationException e)
                {
                    e.Data["file"] = file;
                    throw;
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Harvest the registry values written by calling DllRegisterServer on the specified file.
        /// </summary>
        /// <param name="file">The file to harvest registry values from.</param>
        /// <returns>The harvested registry values.</returns>
        public Wix.RegistryValue[] HarvestRegistryValues(string file)
        {
            this.isFile64Bit = ATLDllHarvester.Is64Bit(file);

            using (var registryHarvester = new ATLRegistryHarvester(true))
            {
                try
                {
                    string options = (useDash ? "-RegServer" : "/RegServer");

                    if (isFile64Bit)
                    {
                        StartProxyProcess64(file, options);
                    }
                    else
                    {
                        ProcessWithInjectedDll.Start(file, options, "RegRedir.dll");
                    }

                    return(registryHarvester.HarvestRegistry());
                }
                catch (Exception e)
                {
                    e.Data["file"] = file;
                    throw;
                }
            }
        }