Share this page

# Call functions from external DLLs

You can call functions that are defined in external DLLs. By calling external functions from your script, you can reduce the memory footprint of your script and the overall runtime.

In this topic:

Back to top

## Load a DLL locally

You can use the lr_load_dll function to load a DLL into a single Vuser script. Once the DLL is loaded, you can call any function defined within the DLL without having to declare it in your script.

To load a DLL locally:

1. In a C Vuser script, add an lr_load_dll function to load the DLL at the beginning of your script. Place the statement at the beginning of the vuser_init section. lr_load_dll replaces the ci_load_dll function.

Use the following syntax:

    lr_load_dll( library_name);

Note that for Linux platforms, DLLs are known as shared libraries. The extension of the libraries is platform dependent.

2. Call the function defined in the DLL in the appropriate place within your script.

   In the following example, the insert_vals function, defined in orac1.dll, is called, after the creation of the Test_1 table.

   Example: int LR_FUNC Actions(LR_PARAM p) { lr_load_dll("orac1.dll");

   lrd_stmt(Csr1, "create table Test_1 (name char(15), id integer)\n", -1,
   1 /*Deferred*/, 1 /*Dflt Ora Ver*/, 0); lrd_exec(Csr1, 0, 0, 0, 0, 0);

   /* Call the insert_vals function to insert values into the table. */
   insert_vals();
   lrd_stmt(Csr1, "select * from Test_1\n", -1, 1 /*Deferred*/, 1 /*Dflt Ora Ver*/, 0); lrd_bind_col(Csr1, 1, =;NAME_D11, 0, 0); lrd_bind_col(Csr1, 2, =;ID_D12, 0, 0); lrd_exec(Csr1, 0, 0, 0, 0, 0); lrd_fetch(Csr1, -4, 15, 0, PrintRow14, 0); ...

Note: You can specify a full path for the DLL. If you do not specify a path, lr_load_library searches for the DLL using the standard sequence used by the C++ function, LoadLibrary on Windows platforms. On Linux platforms you can set the LD_LIBRARY_PATH environment variable (or the platform equivalent). The lr_load_dll function uses the same search rules as dlopen. For more information, see the Unix help 'man' page for dlopen.

Back to top

## Load a DLL globally

You can load a DLL globally, to make its functions available to all your Vuser scripts, by adding statements to the vugen.dat file.

Once the DLL is loaded, you can call any function defined within the DLL, without having to declare it in your script.

To globally load DLLs:

1. Add a list of the DLLs you want to load to the appropriate section of the mdrv.dat file, located in your application's dat folder.

   Use the following syntax:

   `PLATFORM_DLLS=my_dll1.dll, my_dll2.dll, ...`

   replacing the word PLATFORM with your specific platform. For a list of platforms, see the beginning section of the mdrv.dat file.

   For example, to load DLLs for Winsock Vusers on an NT platform, include the following section in the mdrv.dat file:

   Example: `[WinSock]`

   `ExtPriorityType=protocol`

   `WINNT_EXT_LIBS=wsrun32.dll`

   `WIN95_EXT_LIBS=wsrun32.dll`

   `LINUX_EXT_LIBS=liblrs.so`

   `SOLARIS_EXT_LIBS=liblrs.so`

   `HPUX_EXT_LIBS=liblrs.sl`

   `AIX_EXT_LIBS=liblrs.so`

   `LibCfgFunc=winsock_exten_conf`

   `UtilityExt=lrun_api ExtMessageQueue=0`

   `ExtCmdLineOverwrite=-WinInet No`

   `ExtCmdLineConc=-UsingWinInet No`

   `WINNT_DLLS=``user_dll1``.dll,` `user_dll2``.dll, ...`

2. Call the function defined in the DLL in the appropriate place within your script.

Back to top

See also:

- Advanced

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 25.1-25.3 All View Local Help Center View Online Help Center Version: