views:

32

answers:

2

I've written an NPAPI plugin which, if I place it in %ProgramFiles\Mozilla FireFox\plugins, instantiates and runs correctly. However, because I'd like it to work with other browsers as well, my preference would be to register it in HKLM\Software\MozillaPlugins\, as described here. So in my installer, I create these registry entries:

[HKEY_LOCAL_MACHINE\SOFTWARE\MozillaPlugins\@alanta.com/WinVncCtl]

"ProductName"="WinVnc NPAPI Control"

"Path"="C:\Program Files\Alanta\WinVncCtl.dll"

[HKEY_LOCAL_MACHINE\SOFTWARE\MozillaPlugins\@alanta.com/WinVncCtl\MimeTypes]

[HKEY_LOCAL_MACHINE\SOFTWARE\MozillaPlugins\@alanta.com/WinVncCtl\MimeTypes\application/x-alanta-vnc]

"Description"="Alanta's VNC Server NPAPI Plugin"

And, of course, my installer is placing the WinVncCtl.dll file in the correct place. (I've also tried renaming it to npWinVnc.dll, under the theory that maybe it needs to start with "np", with no dice. I've also tried various combinations of version tags, MIME types, etc.)

I'm instantiating it like so:

vncDiv.innerHTML = "<object id='vncServerControl' classid='@alanta.com/WinVncCtl' type='application/x-alanta-vnc' />";

But it doesn't seem to instantiate that way. However, as mentioned above, if I leave out the classid in the object tag, and simply place the file npWinVnc.dll in my plugins directory, life is good.

Any thoughts about what might be going wrong with my approach?

+1  A: 

So I haven't been able to get it to work the way that the docs say that it should. But this particular combination seems to be successful:

(1) The file name apparently has to begin with "np", so I renamed it to "npWinVnc.dll", and adjusted the registry entries appropriately:

[HKEY_LOCAL_MACHINE\SOFTWARE\MozillaPlugins\@alanta.com/WinVncCtl]

"ProductName"="WinVnc NPAPI Control"

"Path"="C:\Program Files\Alanta\npWinVnc.dll"

[HKEY_LOCAL_MACHINE\SOFTWARE\MozillaPlugins\@alanta.com/WinVncCtl\MimeTypes]

[HKEY_LOCAL_MACHINE\SOFTWARE\MozillaPlugins\@alanta.com/WinVncCtl\MimeTypes\application/x-alanta-vnc]

"Description"="Alanta's VNC Server NPAPI Plugin"

I knew that files in the plugins directory needed to start with "np", but apparently it's also necessary for files registered directly to start with "np" as well. That seems like a screwy (and undocumented!) requirement to me, but it's apparently the way it is.

(2) If you specify a ClassId in the <object> tag (even if you also specify a MIME type), it doesn't seem to work, so you need to JUST specify a MIME type, like so:

vncDiv.innerHTML = "<object id='vncServerControl' type='application/x-alanta-vnc' />";

That particular combination got it working for me. I'd prefer to use the ClassID as well, because it would disambiguate between DLLs in the plugins directory and DLLs that were placed by the installer, but that's not critical. I'm still open to suggestions as to why the ClassId doesn't work, though. (I tried looking through the Mozilla source code, but decided that my time could be better spent somewhere around line 1000 of nsObjectFrame.cpp :-(.)

Ken Smith
+1  A: 

For what you're doing, you may also want to at least look at the FireBreath source code; there are a lot of good examples there and the framework is great (confession: I wrote it) by itself. However, it is open source and you can use it as you wish.

http://firebreath.org

Taxilian