lr_load_dll
Loads an external DLL.
int lr_load_dll( const char *library_name);
| Alphabetical Listing - C Language Utility Functions |
Arguments
| Name | Comments |
|---|---|
| library_name | The name of a DLL (Windows) or shared object (Linux). |
The lr_load_dll function loads a DLL (Windows) or shared object (Linux) allowing you to call an external function when replaying using the C interpreter. Once you load the DLL, you can call any function defined in the DLL, without having to declare it.
You can specify a full path for the DLL.
On Windows platforms, except for the SAP GUI protocol, if you do not specify a path, lr_load_dll searches for the DLL using the standard sequence used by the C++ function, LoadLibrary.
When using the SAP GUI protocol, you must specify the full path. There is no support for searching for the DLL.
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 man pages for dlopen or its equivalent.
Return Values
This function returns 0 on success, 10 if an out of memory condition resulted, or 11 if the file was not found.
Parameterization
You cannot use standard parameterization for any arguments in this function.
Example
In the following example, lr_load_dll is used to load user32.dll so that a standard Windows message box can be displayed during script replay, then to load kernel32.dll to use file functions.:
WIN32_FIND_DATA fdFile;
HANDLE hFind = NULL;
char *filepath;
char sPath[2048];
lr_load_dll("user32.dll");
MessageBoxA(NULL, "This is the message body", "message_caption", 0);
filepath = lr_eval_string("{UploadDirectoryPath}");
lr_load_dll("kernel32.dll");
sprintf(sPath, "C:\\TEMP\\*.*");
// see http://www.win7dll.info/kernel32_dll.html
if((hFind = (void*) FindFirstFileA(sPath, &fdFile)) == INVALID_HANDLE_VALUE)
{
lr_message("Path not found: [%s]\n", sPath);
lr_abort();
}

