{"id":984,"date":"2022-12-05T08:31:31","date_gmt":"2022-12-05T08:31:31","guid":{"rendered":"https:\/\/www.softwaretestingstuff.com\/?p=984"},"modified":"2023-03-06T06:46:26","modified_gmt":"2023-03-06T06:46:26","slug":"creating-a-vuser-script-with-visual-c","status":"publish","type":"post","link":"https:\/\/www.softwaretestingstuff.com\/2013\/09\/creating-vuser-script-with-visual-c.html","title":{"rendered":"Creating a Vuser Script with Visual C"},"content":{"rendered":"\n
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:<\/p>\n\n\n\n
\n
In Visual C, create a new project \u2013 dynamic link library (dll). Select File > New<\/strong>and click the Projects tab.<\/li>\n\n\n\n
In the Wizard, select empty dll<\/em><\/li>\n\n\n\n
Add a new cpp<\/em> file with 3 exported function: init<\/em>, run<\/em>, end<\/em><\/li>\n\n\n\n
Add library file lrun50.lib<\/li>\n\n\n\n
Select the C\/C++ tab and select Code generation<\/strong> (Category) > Use Run Time library<\/strong> (List).Change it to: Multithreaded dll<\/strong><\/li>\n\n\n\n
Select the C\/C++ tab and select Preprocessor<\/strong> (Category) > Preprocessor definitions<\/strong> (edit field) Remove _DEBUG<\/li>\n\n\n\n
Add code from your client application, or program as you normally would<\/li>\n\n\n\n
Enhance your script with Vuser API functions. For example, lr_output_message<\/strong>to issue messages, lr_start_transaction<\/strong> to mark transactions, and so forth<\/li>\n\n\n\n
Build the project. The output will be a DLL<\/li>\n\n\n\n
Create a directory with the same name as the DLL and copy the DLL to this directory<\/li>\n\n\n\n
In the lrvuser.usr<\/strong> file in the Template<\/em> directory, Update the USR file keyBinVuser<\/em> with the DLL name: BinVuser=<DLL_name<\/em>><\/li>\n<\/ul>\n\n\n\n
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.<\/p>\n\n\n\n