0
votes

I am developing an NPAPI Firefox plugin and I have a question.

I need to load a third-party DLL (such as D:\mydll.dll), but on some computers mydll.dll is not in the system path or in c:\windows\system32 and I get loading errors.

Here is the code:

SetCurrentDirectory ("d:\");
m_hModule = LoadLibrary ("mydll.dll");

LoadLibrary returns 126. I checked with DEPENDS.EXE to view the dependent modules and everything looks fine. I do not know what the problem is.

Another problem is that I want the plug-in to work in Safari (my safari is version 5.17). I copy it into Safari's Plugins directory and it tells me it cannot find the plug-in. I want to know how to solve this.

Thank you, and please excuse my poor English.

1
I still can not understand why can not load third-party DLL, why the same DLL can be loaded in the system pathllf llf
First of all, I recommend that you only ask one question at a time; these are two completely different questions.taxilian

1 Answers

2
votes

Setting the current directory will not always work when in a plugin because you don't own the process. The command that you want is SetDllDirectory.

SetDllDirectory("D:\");
m_hModule = LoadLibrary("mydll.dll");

Of course, I don't recommend that you ever assume a DLL is in the root of the drive =] What I would do is put the DLL you need in the same directory as the plugin DLL and then you can get the path of the DLL using GetModuleFilename.

For installing, rather than putting the plugin in the plugins/ directory in the firefox (or safari) directory you should install it through the windows registry. This will make it visible for firefox, chrome, and safari.

You may want to consider using FireBreath instead of implementing the NPAPI interfaces yourself; it takes care of most of the tricky parts and leaves you free to focus on the important parts of your plugin.