Troubleshooting
Problem
This technote describes how to invoke a Microsoft .NET dll function from within an IBM Rational Robot SQABasic script.
Resolving The Problem
From a Robot SQABasic script you can invoke a library function that is implemented in a DLL. Enclosed below is an example of C++ code that contains the function: myDllFunction(). This code can be built into a DLL (using Visual Studio 6.0 or .NET) allowing calls to myDllFunction() from SQABasic. Note: The same mechanism should also work with DLLs written in C#, Visual Basic (VB) and other programming languages of .NET.
#include "stdafx.h" #include "mylib.h" extern "C" { __declspec(dllexport) long __cdecl myDllFunction( char* s1, char* s2 ) { return 1; } } Below you can find the Robot SQABasic script that invokes the function from the DLL library. Note that the library is stored under: D:\release\mylib.dll. Declare Function myDllFunction Lib "D:\release\mylib.dll" (Byval s1 As String, Byval s2 as String) as integer Sub Main Dim Result As Integer Result = 0 Result = myDllFunction("string1", "string2") print Result End Sub |
For additional information on how to export functions from a DLL, please refer to the MSDN Home Page and search for __declspec.
All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
|---|
Was this topic helpful?
Document Information
Modified date:
16 June 2018
UID
swg21166575