LoadRunner Mix the custom function in the DLL

xiaoxiao2021-04-05  250

Calling a custom function in the dynamic link library in LoadRunner, writing a very simple example, I think the complex application process should also be almost.

Be a DLL file yourself:

Open the VC, create a new project: project-> Win32 Dynamic-link library method, follow the wizard, select "A DLL That Exports Some Symbols" when selecting the type, and then the VC will open the workspace after completion.

Add a custom function to zltest.cpp, very simple, is the return value.

Int Fun (int X)

{

Return X;

}

Add the following code in Zltest.h:

EXTERN "C" _Declspec (dllexPort) int fun (int x);

Run, generate ZLTEST.DLL and ZLTEST.LIB files in the debug folder.

Copy the zltest.dll file to the folder of the LoadRunner script, add the code in the LoadRunner script:

INT x = 1000;

Int R;

Ret = lr_load_dll ("zltest.dll"); // Load DLL library

RET = fun (x); // Call the custom FUN (INT X) function in the zltest.dll file

LR_output_message ("DLL value =% D", RET); // output function return value

This calls the custom function in the LoadRunner script.

转载请注明原文地址:https://www.9cbs.com/read-132031.html

New Post(0)