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 > Newand 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_messageto 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 keyBinVuser 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.