取消注册COM(高级安装程序)的问题

时间:2013-04-05 08:49:12

标签: c++ windows com advanced-installer

问题的定义:

在COM取消注册期间暂停一段时间并说The setup was unable to automatically close all requested applications. Please ensure that the applications holding files in use are closed before continuing with the installation。但实际上我的扩展程序已成功卸载并卸载。

环境定义:

我为测试创建了一些虚拟shell命名空间扩展。它实现IContextMenu并且所有方法都返回S_OK并且不执行任何操作,而rgs文件是

HKCR
{
    xxx.sergz.dummyShellExt.1 = s 'DummyNSE Class'
    {
        CLSID = s '{6C0FBE00-9898-4BB0-806F-3ED7D2F1170D}'
    }
    xxx.sergz.dummyShellExt = s 'DummyNSE Class'
    {
        CurVer = s 'xxx.sergz.dummyShellExt.1'
    }
    NoRemove CLSID
    {
        ForceRemove {6C0FBE00-9898-4BB0-806F-3ED7D2F1170D} = s 'DummyNSE Class'
        {
            ProgID = s 'xxx.sergz.dummyShellExt.1'
            VersionIndependentProgID = s 'xxx.sergz.dummyShellExt'
            ForceRemove Programmable
            InprocServer32 = s '%MODULE%'
            {
                val ThreadingModel = s 'Apartment'
            }
            TypeLib = s '{3DC947F0-6691-4043-B414-29F749209905}'
            Version = s '1.0'
        }
    }
    NoRemove Directory
    {
        NoRemove Background
        {
            NoRemove ShellEx
            {
                NoRemove ContextMenuHandlers
                {
                   ForceRemove DummyShellExt = s '{6C0FBE00-9898-4BB0-806F-3ED7D2F1170D}'
                }
            }
        }
    }
}


HKLM
{
  NoRemove Software
  {
    NoRemove Microsoft
    {
      NoRemove Windows
      {
        NoRemove CurrentVersion
        {
          NoRemove Shell Extensions
          {
            NoRemove Approved
            {
              val '{6C0FBE00-9898-4BB0-806F-3ED7D2F1170D}' = s 'xxx.sergz Dummy shell extension.'
            }
          }
        }
      }
    }
  }
}

我选择Professional安装程序并仅添加了我的dll文件。在文件属性Registration标签上,我选择Auto register file...Extract registration info...SynchronizationEnabled。在Product Information->Install Parameters->PackageType我选择了64-bit package for x64...

现在我构建MSI并安装扩展。 启动资源管理器,然后右键单击文件夹背景上的某个位置。根据我的日志我的扩展名已加载,并且是DLL_PROCESS_ATTACH和DLL_THREAD_ATTACH几次。

我再次启动MSI并选择Remove。它表示您必须关闭... applications are using files...并且列表中只有Windows Explorer。我选择Automatically close ...并按OK。

所有资源管理器窗口都已关闭,但似乎资源管理器未关闭。

状态为“关闭应用程序”,根据我的日志,dll已经卸载。问题出在这里。 dll已经卸载,但MSI仍在等待某事,然后它显示The setup was unable to automatically close all requested applications. Please ensure that the applications holding files in use are closed before continuing with the installation。 我单击“确定”,然后该过程继续,最后成功删除了我的DLL。

我使用Windows 8 64位。

这种等待的原因是什么,以及无法关闭应用程序的消息。我怎么能搞清楚?

1 个答案:

答案 0 :(得分:0)

是的,这不会起作用,很可能会加载shell扩展,并且MSI不会杀死Explorer.exe。你也不想要,它对用户来说是一个可怕的景象。

您需要使用其他方式取消/注册扩展程序。目前尚不清楚“专业安装人员”的含义。但是你总是可以通过自己修改注册表来取消/注册COM服务器,而不是将它留给DLL来执行此操作。这实际上是推荐的方式。您已经知道.rgs文件中的注册表项。您也可以使用WiX工具集中的Heat.exe收集器。需要通过在下次用户登录时删除它来删除DLL,方法是将其添加到PendingFileRenameOperations注册表项。检查安装程序创建工具是否正确。