My Firefox Plugin development journey (5) -- compile and test the first plugin example: npruntime

Source: Internet
Author: User

I have been busy studying and reading the extension related materials of XUL and FF a few days ago. Today, I suddenly found that
It seems that the extension is not used to implement the tasks. Because the original application is an ActiveX, some parameters will be passed in through the ActiveX control, and
After receiving these parameters, ActiveX interacts with the server and finally calls the local execution program. It seems that I have taken some detours and the direction is wrong. I want to write
Plugin instead of extension.

Corrected the next research plan in time, so let's compile and test a small example provided by Mozilla. The original text is connected here:

Https://developer.mozilla.org/En/Compiling_The_npruntime_Sample_Plugin_in_Visual_Studio
.
The article uses vs2003 as an example. Here I will use vc6 for testing, and I will explain the notes in the steps.

1, first download the relevant source code: http://mxr.mozilla.org/seamonkey/source/modules/plugin/samples/npruntime/
.
I don't know why Mozilla only provides the page format, but does not have a pack, which makes it difficult for me to download and save files one by one.

2. Create a Win32 dynamic-link in vc6.
Library Project, named "nprt ". Note: It is recommended that the project starts with a lower-case NP and has a length of no more than 8 characters, which saves a lot of trouble in the future.

3. Next, select "an empty DLL project" and click "finish ".

4. Add the downloaded source code to the project. Test.html does not need to be added, and nprt. Def is recommended to be added.

5. Compilation is not yet available; otherwise, many errors may occur. Open Project
Settings, go to the C/C ++ tab, select Preprocessor in category
Add the following in definitions:, xp_win32, mozilla_strict_api, xpcom_glue, xp_win, _ x86 _.
Note: If you use VS 2005, you need to add all settings
Meaning: Win32; _ windows; nprt_exports; xp_win32; mozilla_strict_api; xpcom_glue; xp_win; _ x86 _

6. Add xulrunner under Additional include directories
The include path of the SDK can be an absolute or relative path, depending on how you decompress the package. Example: ../xulrunner-SDK/include

7. Select precompiled headers in category and not using precompiled
Headers, OK, close the Project Settings dialog box. Open npp_gate.cpp and comment out the following code:
Jref npp_getjavaclass (void)
{
Return NULL;
}

8. Compile !...... By mistake: Fatal error c1083: cannot open include file: 'npapi. H ':
No such file or directory. I strictly follow the instructions in the tutorial.

9. Search for npapi. h In the xulrunner-SDK directory. It turns out to be under xulrunner-SDK/include.
What if a path is included? Add the directory following step 1;

10. compile! OK.

11. Copy nprt. DLL to the Plugins directory of the FF installation directory, for example, C:/program files/Mozilla.
Firefox/plugins/

12. If FF is on at this time, it doesn't matter. Don't close it (this is good ). Enter about: Plugins in the address bar to see if there is an npruntime.
Scriptable example plugin. If there is one, it indicates ou, FF recognizes our plug-in;

13 bytes open test.html in ff, huh? Why do I still prompt to install the missing plug-in? Use editplusto open test.html.
Sentence: <embed
Type = "application/X-Java-mozilla-npruntime-Scriptable-plugin"
Style = "display: block; width: 50%; height:
100px; ">. Because we didn't add a plug-in named X-Java-mozilla-npruntime-Scriptable-plugin just now
Of course I cannot recognize it.

14. click the button on the page to view simple interactions.

 

OK. The first example is still smooth, and it is better than imagined. Next we should study the code to see how different the FF plug-in is from ActiveX.

Attached references:
Http://xinsync.xju.edu.cn/index.php/archives/2124

Http://mqjing.blogspot.com/2008/09/plugin-firefox-plugin.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.