Loading and Calling the Above DLLs from WinRunner
Loading and calling DLLs from WinRunner is really very simple. There are only 3 steps.
> Load the DLL using the command load_dll.
> Declare the function in the DLL as an external function using the extern function.
> Call the function as you would any other TSL function.
As simple as this is, there are some things you need to be aware of.
* WinRunner has a limited number of variable types; basically, there is string, int, and long. Windows has many different types. Two common types, which may confuse you, are HWND and DWORD. Which WinRunner type do you choose for these? You should declare these as long.
* If we are building a function in a DLL and you are testing it in WinRunner, make sure you unload the DLL in WinRunner using the unload_dll function before you try to recompile the DLL. If we leave the DLL loaded in WinRunner and try to recompile the DLL, you will receive an error message in VC++ that looks like this :
> LINK : fatal error LNK1104: cannot open file "Debug/<project name>.DLL Error executing link.exe
To resolve this error, step through the unload_dll line in WinRunner, then compile the DLL.
* Before shipping a DLL make sure you compile it in Release mode. This will make the DLL much smaller and optimized.