I'm trying to add a new entry into Internet Explorer's right-click context menu. I understand that this can be achieved by creating an HTML file containing JavaScript, and then linking to this from a location in the registry. I have also read that you can also add the HTML to a resource file and compile it into a DLL (see the Microsoft KB: Adding Entries to the Standard Context Menu). This is where I have started to hit problems.
我正在尝试在Internet Explorer的右键单击上下文菜单中添加一个新条目。我知道这可以通过创建包含JavaScript的HTML文件,然后从注册表中的某个位置链接到此文件来实现。我还读过您还可以将HTML添加到资源文件并将其编译为DLL(请参阅Microsoft KB:向标准上下文菜单添加条目)。这是我开始遇到问题的地方。
Here is a bit of background about what I have done so far.
以下是关于我到目前为止所做的一些背景知识。
C:\test.htm
:我在文件C:\ test.htm中有以下JavaScript:
<script type="text/javascript"> alert('Hello, world!'); </script>
REG_SZ
value 'c:\test.htm'
in the registry at the following location:我在以下位置的注册表中添加了一个新的REG_SZ值'c:\ test.htm':
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt
If I now restart IE, my new menu item appears in the context menu. If I select my new menu item, my message box alert appears as expected. So far so good. However, I can't seem to access the script if it's in a DLL. Here are the steps I have taken:
如果我现在重新启动IE,我的新菜单项将出现在上下文菜单中。如果我选择新的菜单项,我的消息框警报将按预期显示。到现在为止还挺好。但是,如果它在DLL中,我似乎无法访问该脚本。以下是我采取的步骤:
'IETest'
in c:\IETest
在VS 2005中创建了一个名为“IETest”的新的Visual C ++类库项目,位于c:\ IETest中
C:\test.htm
file into the default app.rc
resource file. I have changed the ID
to be TEST
将我的C:\ test.htm文件导入默认的app.rc资源文件。我已将ID更改为TEST
在调试模式下编译DLL
改变了要读取的注册表项
res://C:\IETest\debug\IETest.dll/TEST
If I now restart IE and try again, the message box does not appear when I right-click and select my new context menu entry. I have also tried a release build of the DLL without any luck, and also tried replacing the last forward slash with a comma and altering the path single-backslashes to double-slashes.
如果我现在重新启动IE并再次尝试,当我右键单击并选择我的新上下文菜单条目时,不会出现消息框。我也尝试了没有任何运气的DLL的发布版本,并尝试用逗号替换最后的正斜杠并将路径单反斜杠更改为双斜线。
I can only presume that I've done something wrong when creating my DLL. Can anyone point me in the right direction? Is there any way I can examine the compiled DLL to examine the resources and associated IDs?
我只能假设在创建DLL时我做错了。谁能指出我正确的方向?有什么办法可以检查编译的DLL来检查资源和相关的ID吗?
Thanks.
Have you tried having the ID be TEST.html? My guess is that IE doesn't know how to handle the file because it doesn't have an extension listed, but this is totally a guess based off the fact that's how certain MS .dlls identify them (i.e. res://c:\windows\system32\shdoclc.dll/navcancl.htm)
您是否尝试将ID设为TEST.html?我的猜测是IE不知道如何处理该文件,因为它没有列出扩展名,但这完全是基于某些MS .dll识别它们的事实(即res:// c: \ Windows \ System32下\ SHDOCLC.DLL / navcancl.htm)
The only other thing I can think of is to make sure your resources are of type 23.
我能想到的唯一另一件事就是确保你的资源属于23型。
ResourceHacker can view the resource files like you want: http://angusj.com/resourcehacker/
ResourceHacker可以查看您想要的资源文件:http://angusj.com/resourcehacker/
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2009/04/24/b933d7a36992f3ce520d936b82806ecf.html。