SBM AppScript Reference → Additional SBM AppScript Features → Calling Functions in a DLL from SBM AppScript → 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:
Dim sbmLib Dim arg2 Dim path Set sbmLib = CreateObject( "SBMLibrary" ) path = "d:/powderhorn/Tools/ScriptTestTools/build/Release/ Win32DllTest.dll" sbmLib.SetLibraryName( path ) if Not sbmLib.IsLibraryLoaded() Then If Not sbmLib.LoadLibrary() Then Call Ext.WriteStream( _ "<font color=red><b>Test Failed: Unable to load library " _ & "on </b>" ) Call Ext.WriteStream( path ) Call Ext.WriteStream( "</font>\r\n" ) Else Call Ext.WriteStream( "<b>Library load succeeded on ") Call Ext.WriteStream( path ) Call Ext.WriteStream( "</b><br>\r\n" ) End If Else Call Ext.WriteStream( "Library already loaded<br>" ) End If
Copyright © 2007–2018 Serena Software, Inc., a Micro Focus company. All rights reserved.