Interview Questions

Creating C++ DLLs for use with WinRunner

Mercury WinRunner FAQ


(Continued from previous question...)

Creating C++ DLLs for use with WinRunner

Here are the steps for creating a C++ DLL:
1. Create a new Win32 Dynamic Link Library project, name it, and click <Next>.
2. On Step 1 of 1, select "An Empty DLL Project," and click <Finish>.
3. Click <OK> in the New Project Information dialog.
4. Select File New from the VC++ IDE.
5. Select C++ Source File, name it, and click .
6. Double-click on the .cpp file to open it.
7. Create your functions in the following format:

#include "include1.h"
#include "include2.h"
.
.
.
#include "includen.h"

#define EXPORTED extern "C" __declspec(dllexport)

EXPORTED <return type> <function1 name>(<type arg1> <arg1>,
<type arg2> <arg2>,
…,
<type argn> <argn>)
{
<function body>
return <some value>;
}
.
.
.
EXPORTED <return type> <functionN name>(<type arg1> <arg1>,
<type arg2> <arg2>,
…,
<type argn> <argn>)
{
<function body>
return <some value>;
}

8. Choose Build <Project name>.DLL from the VC++ IDE menu.
9. Fix any errors and repeat step 8.
10. Once the DLL has compiled successfully, the DLL will be built in either a Debug directory or a Release directory under your project folder depending on your settings when you built the DLL.
11. To change this setting, select Build Set Active Configuration from the VC++ IDE menu, and select the Configuration you want from the dialog. Click <OK>, then rebuild the project (step 8).
12. All the DLLs types that you are going to create are loaded and called in the same way in WinRunner. This process will be covered once in a later section.

(Continued on next question...)

Other Interview Questions