一、使用regasm.exe将DLL提取出TLB文件
regasm.exe "Tools.HMIBrowserDetector.dll" /tlb
二、使用wix的heat.exe程序
用法如下:
heat file <*.dll> -out <*.wxs>
其中<*.dll>是你用c#编写的activex的dll文件名,<*.wxs>是你要输出的wxs文件名。
heat.exe "Tools.HMIBrowserDetector.dll" -out "Tools.HMIBrowserDetector.dll.wix"
heat.exe "Tools.HMIBrowserDetector.tlb" -out "Tools.HMIBrowserDetector.tlb.wix"
文件生成OK后,打开<*.WXS>文件
1.将其中的<DirectoryRef Id="*">修改成你的目录名,比如<DirectoryRef Id="INSTALLDIR">
2.将<Component Id="*" Guid="PUT-GUID-HERE">中的PUT-GUID-HERE换成你的ACTVIEX的GUID,比如[Guid("3C719C70-EBB6-46A4-B9C5-6A926BDC004C")]的3C719C70-EBB6-46A4-B9C5-6A926BDC004C
最终效果:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLDIR">
<Component Id="cmp2655A93590AF35557BE69214C9637225" Guid="3C719C70-EBB6-46A4-B9C5-6A926BDC004C">
<Class Id="{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}" Context="InprocServer32" Description="xxxxx.Tools.HMIBrowserDetector.BrowserDetector" ThreadingModel="both" ForeignServer="mscoree.dll">
<ProgId Id="HMIBrowser.Detector" Description="xxxxx.Tools.HMIBrowserDetector.BrowserDetector" />
</Class>
<File Id="fil21B157A69D41BF1742AD629A14C5609E" KeyPath="yes" Source="SourceDir\Build\xxxxx.Tools.HMIBrowserDetector.dll" />
<RegistryValue Root="HKCR" Key="CLSID\{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Value="" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}\InprocServer32\2.0.2015.1016" Name="Class" Value="xxxxx.Tools.HMIBrowserDetector.BrowserDetector" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}\InprocServer32\2.0.2015.1016" Name="Assembly" Value="xxxxx.Tools.HMIBrowserDetector, Version=2.0.2015.1016, Culture=neutral, PublicKeyToken=366fc8dc0356ba75" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}\InprocServer32\2.0.2015.1016" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}\InprocServer32\2.0.2015.1016" Name="CodeBase" Value="file:///[#fil21B157A69D41BF1742AD629A14C5609E]" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}\InprocServer32" Name="Class" Value="xxxxx.Tools.HMIBrowserDetector.BrowserDetector" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}\InprocServer32" Name="Assembly" Value="xxxxx.Tools.HMIBrowserDetector, Version=2.0.2015.1016, Culture=neutral, PublicKeyToken=366fc8dc0356ba75" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}\InprocServer32" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
<RegistryValue Root="HKCR" Key="CLSID\{3C719C70-EBB6-46A4-B9C5-6A926BDC004C}\InprocServer32" Name="CodeBase" Value="file:///[#fil21B157A69D41BF1742AD629A14C5609E]" Type="string" Action="write" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLDIR">
<Component Id="cmp71D7A8BD2249AE8FF1BAF63380EBE202" Guid="3C719C70-EBB6-46A4-B9C5-6A926BDC004C">
<File Id="fil4917A9C7209D8355FE869F3A043C0103" KeyPath="yes" Source="$(var.SourceFilesDir)\Tools.HMIBrowserDetector.tlb">
<TypeLib Id="{1CC3C945-DAFF-4E73-A9D3-849540BBA501}" Description="Tools_HMIBrowserDetector" HelpDirectory="dirB3F37FBA6922AB1B836A1A26AE0C3C1E" Language="0" MajorVersion="2" MinorVersion="0">
<Interface Id="{E455B333-58E2-3D50-9E32-2962A5FC9324}" Name="_BrowserDetector" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
</TypeLib>
</File>
</Component>
</DirectoryRef>
</Fragment>
</Wix>
3.保存文件,放到WXI安装工程中去
4.修改文件清单wxs,将上面两个ComponentId加入进去,这样文件就会拷贝过去了