XPCOM - Getting Started

Setup

Following the above blog:

Build

  • We need to regenerate the comp.h and comp.xpt files in the root of the xpcom-test project:

    • Change into the xpcom-test project folder:

      cd C:\development\sample\mozilla\xpcom\xpcom-test\
      
    • Edit the xpidl-build.bat file and update the sdk paths:

      C:\src\xulrunner-1.9.1.3\sdk\bin\xpidl.exe -m header -IC:\src\xulrunner-1.9.1.3\sdk\idl %1
      C:\src\xulrunner-1.9.1.3\sdk\bin\xpidl.exe -m typelib -IC:\src\xulrunner-1.9.1.3\sdk\idl %1
      
    • Regenerate the comp.h and comp.xpt files:

      xpidl-build.bat comp.idl
      
  • Start Visual C++ Express Edition and open the solution file:

    C:\development\sample\mozilla\xpcom\xpcom-test\test.sln
    
  • Edit the project properties changing the location of the header and library files from ..\gecko-sdk\ to ..\\sdk\.

    C:\src\xulrunner-1.9.1.3\sdk\include
    C:\src\xulrunner-1.9.1.3\sdk\lib
    
  • Build the project. The build will create a dll file:

    C:\development\sample\mozilla\xpcom\xpcom-test\Debug\test.dll
    

Deploy

Note: You might need to open a command prompt with Administrator permissions before performing the next few steps.

  • Create a Firefox development profile, Profile

  • Create a folder inside your Firefox profile for your component. I created the component__xpcom-test folder:

    C:\Users\Patrick\AppData\Roaming\Mozilla\Firefox\Profiles\h33vgw96.dev-xpcom-test\component__xpcom-test\
    
  • Copy the comp.xpt and Debug/test.dll files to your component folder:

    cd c:\development\sample\mozilla\xpcom\xpcom-test\
    copy comp.xpt C:\Users\Patrick\AppData\Roaming\Mozilla\Firefox\Profiles\h33vgw96.dev-xpcom-test\component__xpcom-test\
    copy Debug\test.dll C:\Users\Patrick\AppData\Roaming\Mozilla\Firefox\Profiles\h33vgw96.dev-xpcom-test\component__xpcom-test\
    
  • To register the component, run regxpcom:

    cd C:\src\xulrunner-1.9.1.3\bin\
    ..\sdk\bin\regxpcom.exe -x "C:\Users\Patrick\AppData\Roaming\Mozilla\Firefox\Profiles\h33vgw96.dev-xpcom-test\component__xpcom-test\"
    

    Note: It is important to run regxpcom.exe** from the ``bin folder (not sdk/bin) because the command needs some of the dll files in the bin folder.

Test