Interview Questions

Creating MFC DLLs for use with WinRunner

Mercury WinRunner FAQ


(Continued from previous question...)

Creating MFC DLLs for use with WinRunner

1. Create a new MFC AppWizard(DLL) project, name it, and click <Next>.
2. In the MFC AppWizard Step 1 of 1, accept the default settings and click <Finish>.
3. Click <OK> in the New Project Information dialog.
4. Select the ClassView tab in the ProjectView and expand the classes tree. You will see a class that has the following name C<project name>App; expand this branch.
5. You should see the constructor function C<project name>App(); double-click on it.
6. This should open the .cpp file for the project. At the very end of this file add the following definition:
#define EXPORTED extern "C" __declspec( dllexport )
7. Below you will add your functions in the following format:
#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. You will see the functions appear under the Globals folder in the ClassView tab in the ProjectView.
9. Choose Build <Project name>.DLL from the VC++ IDE menu.
10. Fix any errors and repeat step 9.
11. 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.
12. To change this setting, select Build Set Active Configuration from the VC++ IDE menu, and select the Configuration you want from the dialog. Click , then rebuild the project (step 9).
13. 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