1. First install the gecko SDK and decompress it to the local directory such as/home/user/SDK/gecko-SDK/
2. Create guid uuidgen for the main interface class
2. Compile the interface file ***. IDL
3. generate ***. H and ***. xpt file (xpidl-M Header/typelib-w-O/output path/output file name-I/Gecko/IDL path to be compiled ***. IDL file)
4. modify the header file of the generated component ***. h. Add the Macro Protection Code (# ifndef _ my_mycomponent_h _...) at the beginning _...), generate a guid for a component and add the following row to the header file.
First contract ID, then class name, guid
# Define my_component_contractid "@ mydomain.com/xpcomsample/mycomponent1_1"
# Define my_component_classname "A simple XPCOM sample"
# Define my_component_cid guid
5. create the header file of your component ****. h, set ***. copy the code starting with/* header file */In the hfile to this header file and replace _ myclass _ with your class name.
6. Create Your component implementation file ***. cpp and add header file reference.
# Include "****. H"
Copy the code starting with/* implementation file */In the ***. h file to this header file, replace _ myclass _ with your class name, and add the implementation code.
6. Create Your component definition file *** module. cpp and add header file reference.
# Include "nsigenericfactory. H" // Mozilla genericfactory Definitions
# Include "****. H"
Add ns_generic_factory_constructor (mycomponent) to define the constructor of your component.
Add the class name, contract ID, and guid for your component.
Static nsmodulecomponentinfo components [] =
{
{
My_component_classname,
My_component_cid,
My_component_contractid,
Mycomponentconstructor,
}
};
Add ns_impl_nsgetmodule ("*** module", components) to output the preceding definition information to Mozilla.
7. Create makefile and generate ***. So
(Embed:/home/embed/microb-engine/build-tree/Mozilla/build/Autoconf/make-makefile Extentions
Directory Name
Generate the MAKEFILE file in this directory)
/* 8, 9 */
8. Register this component on Mozilla
Copy ***. So and the previously generated ***. xpt to the Mozilla components directory (~ /Firefox/components ,~ /Mozilla/components)
Run the regxpcom command to register the component (you may need to provide the path of the component)
Delete xpti. dat and compreg. dat from the Mozilla path (these two files will be automatically generated when Mozilla restarts next time)
You can also install a file named. autoreg under the touch Mozilla/Firefox installation directory.
9. Test Components
Restart Mozilla or Firefox
Open the *** test.html ** test page and click the "go" button to view the expected results.