Creating a Vuser Script with Visual C
Vuser scripts can be created using Visual C 6.0 or higher. To create a Vuser script with Visual C, please follow the below steps:
- In Visual C, create a new project – dynamic link library (dll). Select File > New and click the Projects tab.
- In the Wizard, select empty dll
- Add a new cpp file with 3 exported function: init, run, end
- Add library file lrun50.lib
- Select the C/C++ tab and select Code generation (Category) > Use Run Time library (List). Change it to: Multithreaded dll
- Select the C/C++ tab and select Preprocessor (Category) > Preprocessor definitions (edit field) Remove _DEBUG
- Add code from your client application, or program as you normally would
- Enhance your script with Vuser API functions. For example, lr_output_message to issue messages, lr_start_transaction to mark transactions, and so forth
- Build the project. The output will be a DLL
- Create a directory with the same name as the DLL and copy the DLL to this directory
- In the lrvuser.usr file in the Template directory, Update the USR file key BinVuser with the DLL name: BinVuser=<DLL_name>
In the following example, the lr_output_messsage function issues messages indicating which section is being executed. The lr_eval_string function retrieves the name of the user. To use the following sample, verify that the path to the Vuser API include file, lrun.h is correct
#include “c:\lrun_5\include\lrun.h”
extern “C” {
int __declspec(dllexport) Init (void *p)
{
lr_output_message(“in init”);
return 0;
}
int __declspec(dllexport) Run (void *p)
{
const char *str = lr_eval_string(“<name>”);
lr_output_message(“in run and parameter is %s”, str);
return 0;
}
int __declspec(dllexport) End (void *p)
{
lr_output_message(“in end”);
return 0;
}
} //extern C end
Popularity: 92% [?]












Leave your response!