Question

Is there a possibility, in any language (c/c++/c#,VB etc I DONT CARE) to export all the COM Registration information (such as clsid, progid, typelib, interface, appid etc)? Or do you know a reliable tool that exports that information including all of the 32 bit and 64 information?

Basically what I wanna do is what regsvr32 does but "in a file" and not write it to the registry. The solution can be a API-Call or Assembly class OR ANYTHING that supports me by doing this or it can be a tool where you are able to export the infos to a file. Please be aware that the tool, if so, should do this for COM as well as for interop assemblies. (I am not interessted in wisecomcaputure or the equivalent of adminstudio)

For clarification my point is here: I am a setup engineer. I basically want to know a way to get all the registration information of a COM or an Interop Object that's normally placed in the registry by calling regsvr32.

I am very glad of any help or hints

Eliane

Was it helpful?

Solution

There is a little-known but very handy API: RegOverridePredefKey. It allows to do exactly what you're looking for:

The RegOverridePredefKey function is intended for software installation programs. It allows them to remap a predefined key, load a DLL component that will be installed on the system, call an entry point in the DLL, and examine the changes to the registry that the component attempted to make. The installation program can then write those changes to the locations intended by the DLL, or make changes to the data before writing it.

Follow the docs for further details. Once you have re-mapped the HKEY_CLASSES_ROOT key and called the COM server's DllRegisterServer, use RegSaveKey to save the re-mapped key to a file, process the file and change the mapping back to HKEY_CLASSES_ROOT.

OTHER TIPS

We use WiX in our company to create installers and gathering this registry information for COM assemblies is often essential in the installation process. Within the WiX suite there is a tool called Heat that basically scrapes this information and puts it in an xml file. This xml is specific to WiX but it may still help you.

An example heat command to do this would be:

C:\Program Files (x86)\WiX Toolset v3.8\bin\Heat.exe dir ..\ExactaRFBinaries\ -cg ExactaRF -dr RFINSTALLFOLDER -srd -var var.RFBasePath -gg -sfrag -suid -out ExactaRF.wxs

It's output would look something like this:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="RFINSTALLFOLDER">
            <Component Id="ContainerObj.dll" Guid="{A23592C5-E88D-4F56-A853-AE62085F9A91}">
                <File Id="ContainerObj.dll" KeyPath="yes" Source="$(var.RFBasePath)\ContainerObj.dll">
                    <TypeLib Id="{8EB27E71-FA87-11D3-A3B3-00104B082353}" Description="ContainerObj 1.0 Type Library" HelpDirectory="RFINSTALLFOLDER" Language="0" MajorVersion="1" MinorVersion="0">
                        <Class Id="{2F467C72-FE8A-11D3-A3B7-00104B082353}" Context="InprocServer32" Description="Containers Class" ThreadingModel="apartment" Programmable="yes">
                            <ProgId Id="ContainerObj.Containers.1" Description="Containers Class">
                                <ProgId Id="ContainerObj.Containers" Description="Containers Class" />
                            </ProgId>
                        </Class>
                        <Class Id="{8EB27E80-FA87-11D3-A3B3-00104B082353}" Context="InprocServer32" Description="Container Class" ThreadingModel="apartment" Programmable="yes">
                            <ProgId Id="ContainerObj.Container.1" Description="Container Class">
                                <ProgId Id="ContainerObj.Container" Description="Container Class" />
                            </ProgId>
                        </Class>
                        <Interface Id="{2F467C71-FE8A-11D3-A3B7-00104B082353}" Name="IContainers" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
                        <Interface Id="{8EB27E7F-FA87-11D3-A3B3-00104B082353}" Name="IContainer" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
                    </TypeLib>
                </File>
            </Component>
            <Component Id="ContainerUseMod.dll" Guid="{48616A97-02AA-4C02-AC5D-F41313B3C0F2}">
                <File Id="ContainerUseMod.dll" KeyPath="yes" Source="$(var.RFBasePath)\ContainerUseMod.dll">
                    <TypeLib Id="{7590DB15-C326-11D3-99A9-0080C84E7C62}" Description="ContainerUseMod 1.0 Type Library" HelpDirectory="RFINSTALLFOLDER" Language="0" MajorVersion="1" MinorVersion="0">
                        <Class Id="{7590DB22-C326-11D3-99A9-0080C84E7C62}" Context="InprocServer32" Description="ContainerUse Class" ThreadingModel="apartment" Programmable="yes">
                            <ProgId Id="ContainerUseMod.ContainerUse.1" Description="ContainerUse Class">
                                <ProgId Id="ContainerUseMod.ContainerUse" Description="ContainerUse Class" />
                            </ProgId>
                        </Class>
                        <Interface Id="{7590DB21-C326-11D3-99A9-0080C84E7C62}" Name="IContainerUse" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
                    </TypeLib>
                </File>
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="ExactaRF">
            <ComponentRef Id="ContainerObj.dll" />
            <ComponentRef Id="ContainerUseMod.dll" />
        </ComponentGroup>
    </Fragment>
</Wix>

WiX is open source so you could probably look at the Heat source code if you want and engineer your own solution as well.

Yes, this is possible. However, the only tool I know of is proprietary and used internally within my company. I'm not sure exactly how it does it and I can't give out the source, unfortunately.

From poking around in the source, it seems like it's getting all the resources of COM DLLs and doing something with the resources, and it's pulling out some info from the type libraries (it's a command-line program that can be given a dll or a tlb).

The code is written in C++ and C# and is about 1400 LOC.

The code makes use of the COM interfaces ITypeLib and ITypeInfo and the TYPEATTR structure. I see calls to ITypeInfo::GetDocumentation, ITypeInfo::GetTypeAttr, LoadTypeLibEx, EnumResourceNames. The output of the program is a .reg file, which appears to be formatted by the tool's code rather than an external library.

We found a little utility called RegCap that Microsoft included with a visual studio extension called Visual Studio Installer Projects. The overall package can be downloaded from the Visual Studio Marketplace (it's a vsix file) here:

https://marketplace.visualstudio.com/items?itemName=VisualStudioClient.MicrosoftVisualStudio2017InstallerProjects

I've had a brief play and it certainly seems to extract the COM registration information. Whether it extracts all the information that regsvr32 would have put into the registry is another matter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top