SBM ModScript Reference → Additional SBM ModScript Features → Calling Functions in a DLL from SBM ModScript → Keeping a Library Loaded Across Script Executions
For performance reasons, you may wish to keep a DLL loaded after your script has finished executing. That way the DLL is already loaded the next time the script executes. To do this, simply check to see if the library has been loaded by calling IsLibraryLoaded() before calling LoadLibrary(). If the library is not loaded, call LoadLibrary() to load it for the first time. As long as your script doesn't call FreeLibrary(), it remains loaded for the next time your script executes.
For example:
var sbmLib = CreateObject( "SBMLibrary" ); var path = "d:/powderhorn/Tools/ScriptTestTools/build/Release/Win32DllTest.dll" sbmLib.SetLibraryName( path ); if ( !sbmLib.IsLibraryLoaded()) { if ( ! sbmLib.LoadLibrary() ) { Ext.WriteStream( "<font color=red><b> Test Failed: " + "Unable to load library on </b>" ); Ext.WriteStream( path ); Ext.WriteStream( "</font>\r\n" ); } else { Ext.WriteStream( "<b>Library load succeeded on "); Ext.WriteStream( path ); Ext.WriteStream( "</b><br>\r\n" ); } } else { Ext.WriteStream( "Library already loaded<br>" ); }
Copyright © 2007–2017 Serena Software, Inc. All rights reserved.