???????????????????????????C??????????lr????????????
???????????????????Loadrunner????????????????????????ɡ?????????????????????????????????????
????1.???????
????1??д???c???????????c??????????????????sum.c
????int sum(int num1??int num2)
????{
????retun num1+num2;
????}
????2)??Loadrunner ?????????httpЭ????????????Lr_Call_cCode
????3)???y????????У????“globals.h”??????????????????????????????檔
#ifndef _GLOBALS_H
#define _GLOBALS_H
//--------------------------------------------------------------------
// Include Files
#include "lrun.h"
#include "web_api.h"
#include "lrw_custom_body.h"
#include "sum.c"????//????????????
//--------------------------------------------------------------------
// Global Variables
#endif // _GLOBALS_H
????4???????"sum.c"?????????“Lr_Call_cCode”??????
????5????action??????£?
????Action()
????{
????int *i?? *j;
????int a=50?? b=50;
????i = &a;
????j = &b;
????lr_message("i+j=%d"??sum(i??j));
????return 0;
????}
????6?????棬?????????????
Virtual User Script started at : 2016-03-28 09:13:52
Starting action vuser_init.
Web Turbo Replay of LoadRunner 11.0.0 for Windows 2008 R2; build 9238 (Feb  1 2011 02:48:36)      [MsgId: MMSG-27143]
Run Mode: HTML      [MsgId: MMSG-26000]
Run-Time Settings file: "C: eststudyLr_Call_cCode\default.cfg"      [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
i+j=100
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
????=============??????????==========================================================
????2.???????????????
?????????action??д????
Action()
{
int *i?? *j;
int a=50?? b=50;
i = &a;
j = &b;
lr_message("i+j=%d"??sum(i??j));
return 0;
}
/*?????action??????дc????*/
int sum(int num1??int num2)
{
retun num1+num2;
}
????????????????????1.
????3.???VC++?????C?????дsum.dll??
???????Loadrunner????????????????
int lr_load_dll( const char *library_name );
note: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.
????dll??????д?????c++??????????????WindowsLoadLibrary.Linux??????????????????ù????????windows???ɡ?