Typelib Generation and Installation with WiX

前端 未结 3 1941
傲寒
傲寒 2020-12-14 17:03

After asking about what Visual Studio does to register a COM Library, it became clear that VS did two things for COM registration:

  1. Registered the COM Library<
3条回答
  •  执念已碎
    2020-12-14 17:31

    The following trick can help with harvesting any registry changes and turning them into a wxs file, including the typelib element you're after.

    1. First, bring your registry back in a state where the type library was not registered:

      c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe /tlb /u mylib.dll
      
    2. Export this clean state of the registry to hklm-before.reg:

      c:\WINDOWS\system32\reg.exe export HKLM hklm-before.reg
      
    3. Register the type library again:

      c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe /tlb mylib.dll
      
    4. Export the new state of the registry to hklm-after.reg:

      c:\WINDOWS\system32\reg.exe export HKLM hklm-after.reg
      
    5. Now we have two text files, hklm-before.reg and hklm-after.reg. Create a diff.reg file which only holds the relevant differences between these. You can find the differences easily with a diffing tool. I like to use the diff tool included in TortoiseSVN since I already use that every day. (WinDiff doesn't seem to work well in this case because of text-encoding issues.)

    6. We can now convert diff.reg into a .wxs by calling heat.exe with the reg command. (Requires wix 3.5 or newer.)

      heat reg diff.reg -out typelib.wxs
      

提交回复
热议问题