如何让两个安装程序setup共享同一个component—— installing shared files(version:installshield develop8.0)

如何让两个安装程序(setup.exe),共享同一个component?
  要实现的效果是,两个程序共享同一个dll,当两个程序中有一个被卸载掉时,这个dll仍存在,不随着第一个卸载而从系统中删除,因为另一个程序还要用它嘛。而当两个程序都被卸载时,这个dll被卸载掉。
  原谅我几乎用了8个多小时才搞明白...痛苦地搜索和阅读过程就不赘述了,总之在帮助里找到一条靠谱的信息,帮助里的索引是Refcounting Shared Files内容如下

Windows Installer has a built-in mechanism for installing shared files. If the component is installed and its Shared property is set to Yes, a reference count in the registry is created, if necessary, and incremented for the component's key file .The installer increments the reference count for any file in a component whether or not you mark the component as shared. However, if no reference count exists, the installer does not create one unless you specify that the component's key file is shared. To specify that your component's key file is a shared file:In the Setup Design view or Components view, select the component in the tree view.In the Components view, select the component in the tree view. Its property sheet opens to the right. Click on the Shared property to display a drop-down list below the property sheet. Select Yes from the drop-down list to set that component's key file as shared. The changes you make are reflected in the property sheet. Windows logo guidelines require you to increment a reference count when installing shared files and to decrement the count when uninstalling. Core component files (which they recommend you not install) should not be refcounted.

  文中我需要的内容就是:“Windows Installer has a built-in mechanism for installing shared files. ...a reference count in the registry is created, if necessary, and incremented for the component's key file”多么靠谱的Windows Installer!!多么靠谱的功能啊!!!
  这个机制就是:如果是shared files,在安装它之后,windows installer就会在注册表的一个键值里为它记数,不管被哪个安装程序安装,装一次加1,装一次加1(incremented)。同理,卸载一次减去1,卸载一次减去1。直到减少到0,此时,这个shared files就会被从系统中删除了。
  所以,实现的过程,有几个问题需要解决:
  如何让一个file成为 shared file?

    这个file是该component的 key file (Set Key File)
    component的GUID是分辨component的唯一标志,也就是说GUID号相同的component,即使是不同的SETUP中也认为是同一个component。就是这条我想通了之后问题才解决的……

  究竟注册表里改了哪个数呢?好奇!
    用我的猥琐小工具终于找到了,提供给大家:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls\

---------------修改如下------------------------------------------
1、把两个SETUP工程中需要共享的文件的component Code改为同一个。
2、把该文件设为KEY FILE
3、把注册表中因为调试而导致HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls\)的该文件的记数不对的那条信息删除
---------------搞定!嘎嘎嘎---------------------------------------

posted @ 2013-01-22 14:00  浑身胆满脸魄  阅读(242)  评论(0编辑  收藏  举报