Interview Questions

Loading and Calling the Above DLLs from WinRunner

Mercury WinRunner FAQ

(Continued from previous question...)

Loading and Calling the Above DLLs from WinRunner

Loading and calling DLLs from WinRunner is really very simple. There are only 3 steps.
1. Load the DLL using the command load_dll.
2. Declare the function in the DLL as an external function using the extern function.
3. 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.
1. 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.
2. If you 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 you 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.
3. Before shipping a DLL make sure you compile it in Release mode. This will make the DLL much smaller and optimized.

(Continued on next question...)

Other Interview Questions