OS/2 Differences, Steps, Files

Differences in a OS/2 Plug-In

The OS/2 interface to plug-ins differs from the Windows documentation in the following ways:

Creating a OS/2 Plug-In

In order to create a OS/2 plug-in you need a C++ complier, such as IBM's Visual Age C++ version 3.0 compiler.

  1. Create a directory on your hard drive for the plug-in project. For example, you might call this directory OS2PLUG.
  2. Download the OS/2 Sample Source Code. Note that the file is compressed.
  3. Use the resulting dialog boxes to save the file in the directory you created for the plug-in project (for example, in C:\OS2PLUG). The compressed file is saved in the directory you specified.
  4. Decompress the file. If you are using pkunzip to decompress the file, use the -d flag to maintain the directory structure stored in the zip file. A readme file is placed in the directory. The following directory structure is created:
  5. Create a new subdirectory to work in. For example, C:\OS2PLUG\SAMPLES\MYPLUG.
  6. Copy all the directories and files in the \sample\npshell directory into your new working directory. In addition, copy into this directory any auxiliary plug-in specific files you have created. For example, you may have written code to implement window handling functionality.
  7. Using your compiler, open the existing makefile in your working directory.
  8. Edit the resource file NPSHELL.RC to include the correct information. You must change the MIME type and the file extension values. For example, if you were creating an AVI plug-in, your resource file would look like this:
    #include "npapi.h"
    RCDATA NP_INFO_ProductVersion { 1,0,0,1, }
    RCDATA NP_INFO_MIMEType       {"Sample/Draw"}
    RCDATA NP_INFO_FileExtents    {"drw"}
    RCDATA NP_INFO_FileOpenName   {"OS/2 Streaming Draw Plugin"}
    
    NOTE: There is a problem in the OS/2 resource compiler that causes an error if the '}' is appended to the first RCDATA type (NP_INFO_ProductVersion in the above example) without the extra comma. You can also move the last brace to the next line to avoid the compile error.
  9. To include multiple MIME types in the plug-in, use a vertical bar to delimit each value in the MIME type. For example, VALUE "MIMEType", "sample/bmp|sample/gif". MIME types must be paired with file extensions and descriptions. For the previous example, the extensions should be "bmp|gif" and the file descriptions would be "bitmap files|gif files".
  10. Save the resource file. The resource file allows Netscape to query the plug-in without having to load it in memory.
  11. Open the file npshell.cpp. This is a compilable shell file that provides the framework for creating a plug-in. By working in npshell.cpp, you simply fill in the necessary code for basic plug-in functionality.
  12. In npshell.cpp, write the code for the functions needed for your plug-in. The Plug-In Application Programming Interface provides a detailed description of each function. You may want to take a look at the other samples.
  13. Save the npshell.cpp file.
  14. Using your compiler, build the project. The file npshell.dll is created. You can get a debug version by specifying OPT=DEBUG on the command line and a dynamically-linked DLL by specifying CRT=DYNAMIC.
  15. Copy the dll file (npshell.dll) into the PLUGINS subdirectory of Navigator. If this directory doesn't exist, create it in the same location as netscape.exe. If the plug-in has associated files, create a separate subdirectory and places the files there.
  16. Restart Navigator. When Netscape Navigator starts up, it find the path to the NETSCAPE.EXE and looks for a PLUGINS subdirectory there (not necessarily the current directory) Navigator then looks for plug-in modules in that directory and any subdirectories.
  17. From the Help menu of Navigator, choose About Plug-ins. A list of all plug-ins in the directory is displayed. You should see your Mime type listed.
  18. Test your plug-in by creating an HTML document.
  19. Navigator will only accept plug-in dlls with file names begining with 'np'.

OS/2 Files

When you unzip the OS/2 sample source code, several subdirectories are automatically created in your working directory.

The contents of each directory include:

\common Directory

\include Directory

\sample\npclock Directory

\sample\npdraw Directory

\samples\npshell Directory

\test Directory