LoadRunner中动态链接函数库(dll)的调用
一、什么时候需要使用动态链接库(dll)
l 不适合录制其业务功能点的业务系统的性能测试(如web客户端本地加密)
l 基于C++语言开发的业务系统的性能测试
二、如何调用
LoadRunner提供了调用动态链接库的函数,函数原型如下:
int lr_load_dll (const char *library_name );
The lr_load_dllfunction loads a DLL (Windows) or shared object (UNIX) allowing you to call anexternal function when replaying using the C interpreter. Once you load theDLL, you can call any function defined in the DLL, without having to declareit.
You can specify a full pathfor the DLL.
On Windows platforms, if youdo not specify a path, lr_load_library searches for the DLL using thestandard sequence used by the C++ function, LoadLibrary .
On UNIX platforms, you can setthe LD_LIBRARY_PATH environment variable (or the platform equivalent). The lr_load_dllfunction uses the same search rules as dlopen. For more information, seethe man pages for dlopen or its equivalent.
参数:library_name,指需要调用的动态链接库的名称。
例如:调用系统函数user32.dll中的MessageBoxA函数。
三、注意事项
l LoadRunner只能调用常规dll中导出的函数,MFC扩展类型的dll不被LoadRunner所支持,而且调用的函数必须是DEF文件中定义的导出函数。
l 在调用过程中,脚本Action部分需要使用到的变量,建议放到Action()函数之前进行声明,而对于变量的赋值等操作则放到函数内部进行,因为如果在函数内部声明变量过多,会报过多局部变量错误信息。