views:

653

answers:

1

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.

Here is a bit of background about what I have done so far.

  • I have the following JavaScript in the file C:\test.htm:
<script type="text/javascript">
    alert('Hello, world!');
</script>
  • I have added a new REG_SZ value 'c:\test.htm' in the registry at the following location:
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:

  1. Created a new Visual C++ Class Library project in VS 2005 named 'IETest' in c:\IETest
  2. Imported my C:\test.htm file into the default app.rc resource file. I have changed the ID to be TEST
  3. Compiled the DLL in debug mode
  4. Altered the registry entry to read
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.

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?

Thanks.

+2  A: 

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)

The only other thing I can think of is to make sure your resources are of type 23.

ResourceHacker can view the resource files like you want: http://angusj.com/resourcehacker/

BarrettJ
Thanks BarrettJ. ResourceHacker has solved the problem. The html resource actually has an ID of 101. I've altered the registry entry to the following and it now works as expected...res://C:\IETest\debug\IETest.dll/101As far as I can see, there doesn't seem to be any way to view or set this value in VS 2005 or 2008?
Craig T