Moray Plugin SDK Documentation
This release of the Plugin SDK can be used by Moray V3.5 (Build 9065) and later.

C++ Support C Support

What's New

Compiler Settings

Visual C++ Plugin Wizard

This release of the SDK features a Visual C++ Plugin Wizard by Amedeo Paglione and Claudio Donati to help you get started with a new plugin project. Thanks to them for making it available to everyone.

You will need to copy the file MorayWizard.awx to the directory ...\DevStudio\SharedIDE\Template on your machine.

Note: Visual C++ 5.0 users

Unfortunately the wizard exhibits a nasty bug when used with Visual C++ 5.0 that could not be tracked down. It crashes Visual Studio after creating the files and before creating the project. Therefore a sample project is included.

You should start a fresh copy of Visual Studio when creating a new plugin with the wizard! Then you won't lose any work or settings that haven't been saved when it crashes.

Here's what to do when you have run the wizard and VC has crashed:

- If there is no DSP file in the directory where you created the Plugin Project, copy the Wizard.dsp file to that directory.
- Rename it to have the same name as the DSW file.
- Edit the DSP file in a text editor and search and replace all instances of "MorayWizard" with the name of the DSP file (without the ".DSP").

Then restart Visual Studio with the DSW file and make sure that the settings are correct by checking this:
- Select Project|Settings (or press Alt-F7).
- Set the "All Configurations" option in the "Settings for" combo box over the files list.
- In the General Tab, in the Microsoft Foundation Classes combo box, choose the "Use MFC in a static library" option.
- In the C/C++ Tab, category Code Generation, choose the 4 byte option in the Struct member alignment combo box.
- Close the Settings window with the "OK" button.

- You may need to add the following source files to the project from the Moray Plugin SDK directory: The project should now compile and function fine.

Visual C++ 5.0 and 6.0 Release and Debug builds

Please note that official releases of Moray are Release builds and are now statically linked to the MFC libraries. This means that plugins compiled with previous versions of the SDK will not work with Moray V3.2 and later. It should be a simple matter of recompiling plugins (changing MFC plugins to static linking).

When your plugin is ready for release, it is best to make a Release build. But to successfully compile a plugin, the compiler must only be set to produce code that has

- 4-byte alignment, i.e. all structs must be aligned on 4-byte boundaries
- no optimizations in the code that interfaces with Moray.

For Visual C++ there are certain optimizations that lead to a crash when initializing a plugin DLL, so you need to disable optimization for release builds.

Note that this is not the default for Visual C++ 5.0 and 6.0. To configure Visual C++ do this:

- Select Project|Settings (or press Alt-F7).
- Go to the C/C++ Tab.
- Select the General category.
- Change the Optimizations to 'Disable' (for Debug and Release builds!)
- Select the Code Generation category.
- Change the Struct Member Alignment from '8 bytes' to '4 Bytes'.

Other C/C++ compilers

While I have fielded questions about other C/C++ compilers (like gcc), no-one has reported back that they successfully compiled a plugin with another compiler.

Ideally, the only thing you should need to use when creating a plugin with another compiler is the file plugin.h. To setup everything correctly, you probably want to check out the helper functions defined in pluginhelpers.hpp.

Delphi Support

There have been questions asked on the SDK Mailing list pertaining to Delphi support. Please check in with us there for the latest details. Go to and join the Moray SDK mailing list.