SBM AppScript Reference → Additional SBM AppScript Features → Calling Functions in a DLL from SBM AppScript → Loading the Library in SBM AppScript
To load a DLL in SBM AppScript, you first need to create an SBM Library object using the CreateObject function call.
Dim ttLib Set ttLib = CreateObject ("TeamTrackLibrary")
Once the object is created, tell the object which DLL you want to call functions in by calling SetLibraryName on the TeamTrackLibrary object. You can specify the path in one of three ways.
Absolute path – You may specify an absolute path to the DLL that you wish to load. For example:
Dim path path = "d:/ScriptTestTools/build/Release/Win32DllTest.dll" ttLib.SetLibraryName( path )
DLL name – You may specify the DLL alone and rely on the ScriptAppPath registry setting to find the library. The ScriptAppPath is a string value in the SBM home registry key that contains a semicolon-separated list of directories in which SBM should look for executables and DLLs that SBM AppScript will use. For example, if HKEY_LOCAL_MACHINE/Software/TEAMSHARE/TEAMTRACK/ScriptAppPath is set to "d:/ScriptTestTools/build/Release", the above example could be re-written as: ttLib.SetLibraryName("Win32DllTest.dll" )
For details on using ScriptAppPath, refer to Setting Script Application Paths.
DLL name without the extension – SBM AppScript also assumes an extension of .dll for any library name. Therefore, the above example could also be written as:
ttLib.SetLibraryName("Win32DllTest")
Additionally, if you are going to use an absolute path to specify the library to load, you must also include the extension. The extension is not assumed when using an absolute path; it is only assumed if you are going to rely on the ScriptAppPath.
Once you've told the library object which library you want to load, call LoadLibrary to actually get the library loaded. For example:
Call ttLib.LoadLibrary()
LoadLibrary() returns a Boolean which indicates the success or failure of the operation. To avoid experiencing a runtime exception, always check the return value of LoadLibrary() prior to calling any functions in the DLL. For example:
If ttLib.LoadLibrary() Then Call ttLib.my_function() End If
Copyright © 2007–2016 Serena Software, Inc. All rights reserved.