在先前无法加载的explorer.exe中重新加载名称空间扩展 [英] Reload a namespace extension in explorer.exe that failed to load previously
问题描述
我有一个 Shell位于(
I have a Shell Namespace Extension that is located (using a virtual folder as its junction point) under MyComputer. It is possible to create a shortcut to my namespace extension. Here I show my namespace extension with a shortcut on the desktop.
如果未安装我的命名空间扩展名 ,则安装时创建的快捷方式将无法按预期解析.
If my namespace extension is not installed, the shortcut that I created when it was installed will be unresolved as expected.
当我的应用程序启动时,它将我的名称空间扩展安装到注册表中.退出时,它将从注册表中删除名称空间扩展名.这对于我的应用程序来说是必需的,因为根据配置,每次运行时加载的代表我的名称空间扩展名的dll可能会有所不同.
When my application starts up, it installs my namespace extension into the registry. When it exits, it removes the namespace extension from the registry. This is necessary for my application because the dll loaded to represent my namespace extension may be different on each run depending on configuration.
当我的应用程序未运行时,并且explorer.exe遇到我(当前未安装)名称空间扩展的快捷方式时,它将尝试在注册表中查找COM组件(该快捷方式包含COM我的命名空间扩展的标识符)-我通过Process Monitor观察到了这一点.稍后,当我的应用程序启动时,我的名称空间扩展名按预期添加在我的电脑"下,但是它无法正常工作-也就是说,尝试浏览到该应用程序(双击)无法正常进行(不执行任何操作) .我通过Process Monitor观察发现,explorer.exe没有重新尝试加载我的命名空间扩展.似乎explorer.exe记得它未能为我的命名空间扩展加载COM组件,因此将不会重试.在这种状态下的症状是:
When my application is not running and explorer.exe encounters the shortcut to my (not currently installed) namespace extension, it attempts to look in the registry for the COM component (the shortcut contains the COM identifier for my namespace extension)--I observed this via Process Monitor. Later, when my application starts up, my namespace extension is added under "My Computer" as expected, but it is non-functional--that is, trying to browse into it (double click) does not work as normal (does nothing). My observation via Process Monitor shows that explorer.exe did not re-attempt to load my namespace extension. It seems that explorer.exe is remembering that it failed to load the COM component for my namespace extension, and thus it will not retry. The symptoms when in this state are:
-
快捷方式显示为未解决
The shortcut shows up as unresolved
名称空间扩展名显示在我的电脑"下,但双击它不起作用.
The namespace extension shows up under My Computer, but double clicking on it does not work.
在这种状态下,找到解决问题的唯一方法是重新启动explorer.exe.
The only way I've found to resolve the issue once I'm in this state is to restart explorer.exe.
是否有一种方法可以使explorer.exe一旦无法成功加载我的命名空间扩展(由于无法解决的快捷方式)而重新尝试加载它,而不必重新启动explorer.exe?
Is there a way to get explorer.exe to retry to load my namespace extension once it has already failed to load it once (due to the unresolved short-cut) without having to restart explorer.exe?
这里是如何从头开始创建和观察问题的演练.这涉及使用称为" Shell实例对象(而不是我真正的名称空间扩展名).我使用它是为了简单起见,并表明它与我的特定名称空间扩展无关.该示例名称空间扩展的全部作用是在我的电脑"下创建一个图标,该图标将浏览到您的%TEMP%目录.
Here is a walk through of how to create and observe the issue from scratch. This involves using a "built in" Microsoft namespace extension called a Shell Instance Object (rather than my real namespace extension). I used this for simplicity as well as to show that it is not related to my specific namespace extension. All this sample namespace extension does is creates an icon under "My Computer" that will browse into your %TEMP% directory.
-
安装名称空间扩展并将其注册在我的电脑"下.为此,请在注册表中输入以下内容:
Install the namespace extension and register it under "My Computer". To do this, enter the following into the registry:
HKEY_CURRENT_USER\Software\Classes\CLSID
{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}=REG_SZ_EXPAND:"My Namespace Extension"
DescriptionID=REG_DWORD:0x00000008
System.IsPinnedToNameSpaceTree=REG_DWORD:0x00000001
DefaultIcon=REG_EXPAND_SZ:"%SystemRoot%\system32\main.cpl,9"
InProcServer32=REG_EXPAND_SZ:"%SystemRoot%\system32\shdocvw.dll"
ThreadingModel=REG_SZ:"Apartment"
ShellFolder
Attributes=REG_DWORD:0x60000000
Instance
CLSID=REG_SZ:"{0AFACED1-E828-11D1-9187-B532F1E9575D}"
InitPropertyBag
Attributes=REG_DWORD:0x00000011
Target=REG_SZ_EXPAND:"%TEMP%"
这是一个.reg文件,它将为您自动执行该操作:
Here is a .reg file that will automate that for you:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}]
@="My Namespace Extension"
"System.IsPinnedToNameSpaceTree"=dword:00000001
"DescriptionID"=dword:00000008
[HKEY_CURRENT_USER\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}\DefaultIcon]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,61,00,\
69,00,6e,00,2e,00,63,00,70,00,6c,00,2c,00,39,00,00,00
[HKEY_CURRENT_USER\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}\InProcServer32]
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,68,00,\
64,00,6f,00,63,00,76,00,77,00,2e,00,64,00,6c,00,6c,00,00,00
"ThreadingModel"="Apartment"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}\Instance]
"CLSID"="{0AFACED1-E828-11D1-9187-B532F1E9575D}"
[HKEY_CURRENT_USER\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}\Instance\InitPropertyBag]
"Attributes"=dword:00000011
"Target"=hex(2):25,00,54,00,45,00,4d,00,50,00,25,00,00,00
[HKEY_CURRENT_USER\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}\ShellFolder]
"Attributes"=dword:60000000
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\Namespace\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}]
@="My Namespace Extension"
这时,打开浏览器窗口并浏览我的电脑"时,应该看到我的命名空间扩展名".浏览其中应该会显示您的%TEMP%目录文件夹/文件.
At this point, when you open an explorer Window and navigate through "My Computer", you should see the "My Namespace Extension". Browsing into it should reveal your %TEMP% directory folders/files.
通过将我的命名空间扩展名"拖动到桌面上,在桌面上创建我的命名空间扩展名"的快捷方式.
Create a shortcut on your desktop to the "My Namespace Extension" by dragging the "My Namespace Extension" to the desktop.
从注册表中完全删除名称空间扩展注册.您可以通过手动删除上面的键或运行以下.reg文件来做到这一点:
Completely remove the namespace extension registration from the registry. You can do that by manually removing the above keys or by running the following .reg file:
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}]
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\Namespace\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}]
此时重新启动explorer.exe(或重新启动).当explorer.exe启动时,它将尝试解析桌面上的快捷方式.这样,它将尝试将COM组件定位在HKEY_CURRENT_USER\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}
处,但是将无法定位.打开资源管理器窗口中的我的电脑",然后观察到我的命名空间扩展名"不存在.还要注意,快捷方式显示为未解决.
Restart explore.exe at this point (or do a reboot). When explorer.exe starts up, it will try to resolve the shortcut on your desktop. In doing so, it will attempt to locate the COM component at HKEY_CURRENT_USER\Software\Classes\CLSID\{0672A6D1-A6E0-40FE-AB16-F25BADC6D9E4}
, but it will be unable to. Open an explorer window to "My Computer" and observe that the "My Namespace Extension" does not exist. Also notice that the shortcut shows as unresolved.
通过重新应用步骤1中的注册表更改来重新安装名称空间扩展.
Re-install the namespace extension by re-applying the registry changes from step 1.
刷新我的电脑"窗口.此时,您将处于有问题的状态,可以在我的电脑"下看到名称空间扩展,但是尝试浏览到该名称扩展将不起作用.
Refresh your "My Computer" window. At this point you will be in the problematic state where you can see the namespace extension under "My Computer", but trying to browse into it does not work.
如果此时重新启动explorer.exe,问题将消失.这是因为当explorer.exe尝试解决该快捷方式时,它能够加载名称空间扩展COM组件,因为该组件当前已在注册表中注册.
If you restart explorer.exe at this point, the issue will go away. This is because when explorer.exe tries to resolve the shortcut it is able to load the namespace extension COM component because it is currently registered in the registry.
附加说明
-
我真正的名称空间扩展是用C ++编写的.
Additional notes
My real namespace extension is written in C++.
I'm using SHChangeNotify to get the namespace extension to appear/disappear under "My Computer" without requiring a manual refresh, but that does not cause the namespace extension to attempt to reload.
Perhaps surprisingly, namespace extensions that are registered using the desktop.ini approach with .ShellClassInfo and CLSID does not appear to suffer from this problem. Unfortunately, I cannot use this approach as I need to have my namespace extension under "My Computer".
推荐答案
You've got to rummage through the Shell documentation quite a bit (always a chore) to find
SHFlushSFCache()
.当更改特殊文件夹的路径时,将调用SHFlushSFCache.这样可以确保使用注册表中存储的更新路径,而不是缓存值.
SHFlushSFCache is called when the path to a special folder is changed. This ensures that the updated path stored in the registry is used rather than the cached value.
不幸的是,该例程被标记为已贬值",但是它似乎仍然可以在Windows 10上运行.
Unfortunately, this routine is marked as "depreciated", but it still seems to work on Windows 10.
调用
SHFlushSFCache()
;应该会强制 explorer.exe 重新加载它.Call
SHFlushSFCache()
after (re-)registering your namespace; that should force explorer.exe to reload it.这篇关于在先前无法加载的explorer.exe中重新加载名称空间扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!