Loadruuner C语言脚本--如何引用DLL文件


  Loadrunner录制完成HTTP/HTML的C语言脚本后,通常在调脚本的过程中设置一些关联和参数脚本即可调通。而使用到DLL(Dynamic Link Library)文件,即动态链接库文件的场景其实比较少。因为dll文件与脚本一样保存在本地,属于一种本地调用了。一般使用的场景是涉及到一些参数,可能项目中的开发有自己的dll库,需要通过项目自己在dll文件处理之后,才能在脚本中使用。下面介绍一下Loadruuner中如何引用DLL文件。

1.DLL文件简介

以下为百度百科的解释:

DLL(Dynamic Link Library)文件为动态链接库文件,又称“应用程序拓展”,是软件文件类型。在Windows中,许多应用程序并不是一个完整的可执行文件,它们被分割成一些相对独立的动态链接库,即DLL文件,放置于系统中。当我们执行某一个程序时,相应的DLL文件就会被调用。一个应用程序可使用多个DLL文件,一个DLL文件也可能被不同的应用程序使用,这样的DLL文件被称为共享DLL文件。 

相关链接:

DLL文件--百度百科


2. Loadrunner相关函数

//C Language 
int lr_load_dll( const char *library_name ); 


详细解释如下,可以参考Loadrunner自带的帮助文档HP LoadRunner Online Function Reference

library_name
The name of a DLL (Windows) or shared object (UNIX).

The lr_load_dll function loads a DLL (Windows) or shared object (UNIX) 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, if you do not specify a path, lr_load_library searches for the DLL using the standard sequence used by the C++ function, LoadLibrary .

On UNIX 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.


3. Loadruuner中DLL文件的使用

示例脚本如下:

int passwordLength;
char encryptedPassword[17];

lr_load_dll("EncryptLib.dll");
	
passwordLength=des3Encrypt(lr_eval_string("{password}"),encryptedPassword);//des3Encrypt函数为EncryptLib.dll库中的函数,函数详细说明需详见库文件的说明文档


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值