Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

HMODULE mod = LoadLibrary("maxwell.mll");
if(!mod) { /* error handling */ }
// GetMaxwellMayaAPIProc is defined in MaxwellMayaAPI.h.
GetMaxwellMayaAPIProc entryPoint = (GetMaxwellMayaAPIProc)GetProcAddress(mod, "GetMaxwellMayaAPI");
if(!entryPoint) { /* error handling */ }
MaxwellMayaAPI* api = NULL;
MaxwellMayaAPIInitStatus initStatus = entryPoint(MAXWELL_MAYA_API_VERSION, &api);
if(initStatus != MaxwellMayaAPIInitStatus_OK) { /* error handling */ }
// We can safely decrement the usage count on the library now, since the Maxwell plug-in is loaded
// by Maya too,
 so this will not unload the code.
FreeLibrary(mod);

...

If the function fails, the API interface pointer will also be set to NULL. The MaxwellMayaAPI class contains a static inline method called LoadAPI() which handles all the details of opening the Maxwell plug-in and querying the interface pointer on all supported platforms. This method will return NULL if an error occurs. If you want to load and call the entry point yourself and do not want LoadAPI() to be declared, define the macro MAXWELL_MAYA_NO_LOAD_HELPER before including MaxwellMayaAPI.h.

...