mudiziqi1 Absent Member.
Absent Member.
3757 views

how to use external DLL in silk performer

hi,

what I am doing now is to call methods inside of external DLL using silk performer.

Based on the silk performer document, I know that I need to declare the external DLL and the methods, and then call the methods in transaction.

However, I still don't understand how I can convert the program language into BDL.

Below is an example that the DLL called by other program language:

a aObj= new a();
aObj.Addr = "localhost";
aObj.Port = 2010;

b bObj= c.d(aObj);
bObj.Timeout = 10;

e eObj = new e();
eObj.LoginID = "aa";
eObj.Password = "aa";

f fObj = bObj.Login(eObj);

Is there anyway to convert this into BDL?

thanks!

Tags (2)
0 Likes
4 Replies
Micro Focus Contributor
Micro Focus Contributor

RE: how to use external DLL in silk performer

Hi

You just declare the dll and its method including parameters and then pass in the parameters to the function like so:

benchmark WebBenchmarkName

use "WebAPI.bdh"

var      

// Windows API - kernel32.dll

dll "kernel32.dll"

  "CreateDirectoryA"                  // create a directory

   function CreateDirectoryA(inout string, inout string allownull): long;      

dcluser  

 user

   WebUser

 transactions

   TCreate       : 1;

dcltrans

 transaction TCreate

 var

   sFolder: string;

 begin

   sFolder:="C:\\jonnyg";

   wait 0.5;

   CreateDirectoryA(sFolder, NULL);

   Print("Created Directory "+ sFolder);

 end TCreate;

This example uses kernel32.dll and full documentation on its methods is available here:

www.geoffchappell.com/.../api

0 Likes
Micro Focus Contributor
Micro Focus Contributor

RE: how to use external DLL in silk performer

hi mudiziqi,

silk performer just supports "functional dll" interfaces, there is no way to instantiate/access objects exported via a dll interface using BDL. sorry for the bad news.

if you need to handle "objects" from your script i suggest to write another custom dll providing a functional interface, loading your initial dll, passing the required dynamic parameters via functions, and implementing the object oriented stuff there.

cheers,

udo

Tags (3)
0 Likes
mudiziqi1 Absent Member.
Absent Member.

RE: how to use external DLL in silk performer

Hi Jonny,

Thanks for your example!

But the issue that I can't handle is the parameters.

Example 1: a aObj= new a();

I need to declare function "a" before transaction. There is no parameter in above method. However, BDL requires me to enter a parameter. What should I enter? What kind of data type I should enter?

Example 2: b bObj= c.d(aObj);

For method "d", the parameter passed in is an object. As I know, silk performer doesn't have such data type. So how can I convert this?

Please kindly correct me if I am wrong!

Thanks for your greate greate help! 🙂

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: how to use external DLL in silk performer

As Udo mentioned, you need to create helper DLL to wrap the object oriented stuff. Usually, we return the pointer to an object as int. Be very careful with memory - a small memory leak can turn out huge in a load test.

e.g. the interface could look like this:

int CreateA(char* host, int port)
{
  a aObj= new a();
  aObj.Addr = host;
  aObj.Port = port;
  return static_cast<int>(a);
}

void DestroyA(int handleOnA)
{
  a aObj = static_cast<a>(handleOnA);
  delete aObj;
}

int CreateB(int handleOnA)
{
  a aObj = static_cast<a>(handleOnA);
  b = c.d(a);
  return static_cast<int>(b);
}

void DestroyB(int handleOnB)
{
  b bObj = static_cast<b>(handleOnB);
  delete bObj;
}

int CreateE(char* login, char* pw)
{
  ...
}

void DestroyE(int handleOnE)
{
  e eObj = static_cast<e>(handleOnE);
  delete eObj;
}

or even simpler, do everything in one big method:

FDoLoginMagic(char* host, int port, char* login, char* pw)
{
 ...
}

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.