Share this page

# Work with C functions

This topic contains tips for using C code functions with your TruClient 2.0 - Web scripts.

In this topic:

## Using C functions

C functions are defined in the C-functions.c file. During replay, they can be called from an Evaluate C step.

You drag and drop an Evaluate C step from the Steps box Miscellaneous tab, and set the Function Name value to the name of the C function to call.

For details, see Steps box Miscellaneous tab.

Back to top

## Define C functions

The C-functions.c file includes an empty main function, void main().

You can add your own C code to the default main function. For example, by calling the following function, “hello” is logged.

Copy code

    void main() {
        lr_message("hello");
    }

You can also define your own functions, for example:

Copy code

    void logHello() {
        lr_message("hello");
    }

Back to top

## Call functions defined in DLL or shared object

You can call C functions defined in DLL (Windows) or a shared object (Linux). This is done using the lr_load_dll(library name) API.

In the following example, the function loads the user32.dll and calls MessageBoxA defined in it. This API displays a message box in Universal Windows Platform.

Copy code

    void showMessageBox()
    {
        lr_load_dll("user32.dll");
        MessageBoxA(NULL, "Hello world!", "message", 0);
    }
    void main()
    {
        showMessageBox();
    }

For details, see lr_load_dll.

Back to top

See also:

- Steps box

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: