Windows Steps, Files

Creating A Windows Plug-In

In order to create a Windows plug-in you need a C++ complier, such as Microsoft's Visual C++ 2.1 compiler.

  1. Create a directory on your hard drive for the plug-in project. For example, you might call this directory plug-in.
  2. Download the Windows 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:\plug-in). 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. Two subdirectories, AVI and shell, are automatically created. A readme file is also placed in the directory. The shell directory contains the files you use to create a new plug-in. The AVI directory contains example files for creating an AVI movie plug-in.
  5. Create a new subdirectory to work in. For example, c:\plug-in\myplug.
  6. Copy all the directories and files in the shell 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. Notice that there are two makefiles, one for 16 bit applications and one for 32 bit applications. Make sure to open the appropriate makefile for your configuration.
  8. Edit the appropriate resource file, NPDLL16.RC2 or NPDLL32.RC2, 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:
    VALUE "MIMEType",        "video/x-msvideo\0"
    VALUE "FileExtents",     "AVI\0"
    VALUE "FileOpenName",    "Video for Windows (*.AVI)\0"
    
    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", "video/x-msvideo | video/quicktime\0"
  9. Save the resource file. The resource file allows Netscape to query the plug-in without having to load it in memory.
  10. 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.
  11. 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 npshell.cpp file in the AVI directory. This is an example of how the npshell.cpp file is used to create an AVI plug-in.
  12. Save the npshell.cpp file.
  13. Using your compiler, build the project. The file npwin16.dll or npwin32.dll is created, depending on your environment.
  14. Copy the dll file (npwin16.dll or npwin32.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.
  15. Restart Navigator. When Netscape Navigator starts up, it checks for plug-in modules in the netscape\plugins directory.
  16. 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.
  17. Test your plug-in by creating an HTML document.

Windows Files

When you unzip the Windows sample source code, two subdirectories, shell and AVI, are automatically created in your working directory. The shell directory contains the files that provide a compilable framework for creating a plug-in. By working in these files you simply fill in the necessary code for basic plug-in functionality.

The AVI directory includes example files that demonstrate a basic plug-in for Netscape Navigator 2.0. The example implements a Microsoft Video for Windows AVI player as a 16-bit and 32-bit plug-in. The plug-in utilizes MCI calls for the video display. You must have Video for Windows installed in order to run the plug-in.The AVI example demonstrates a file-based plug-in. This means that the AVI plug-in handles the data stream once it is complete, rather than as it is being transferred.

The contents of each directory include:

Shell Directory

AVI Directory