Interview Questions

Creating C DLLs for use with WinRunner

Mercury WinRunner FAQ


(Continued from previous question...)

Creating C DLLs for use with WinRunner

These are the steps to create a DLL that can be loaded and called from WinRunner.
1. Create a new Win32 Dynamic Link Library project, name it, and click .
2. On Step 1 of 1, select "An empty DLL project," and click .
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 <OK>.
6. Close the newly created C++ source file window.
7. In Windows Explorer, navigate to the project directory and locate the .cpp file you created.
8. Rename the .cpp file to a .c file
9. Back in the VC++ IDE, select the FileView tab and expand the tree under the Projects Files node.
10. Select the Source Files folder in the tree and select the .cpp file you created.
11. Press the Delete key; this will remove that file from the project.
12. Select Project Add To Project Files from the VC++ IDE menu.
13. Navigate to the project directory if you are not already there, and select the .c file that you renamed above.
14. Select the .c file and click <OK>. The file will now appear under the Source Files folder.
15. Double-click on the .c file to open it.
16. Create your functions in the following format:

#include "include1.h"
#include "include2.h"
.
.
.
#include "includen.h"
#define EXPORTED __declspec(dllexport)
<return type> EXPORTED <function1 name>(<type arg1> <arg1>,
<type arg2> <arg2>,
…,
<type argn> <argn>)
{
<function body>
return <some value>;
}
.
.
.
<return type> EXPORTED <functionN name>(<type arg1> <arg1>,
<type arg2> <arg2>,
…,
<type argn> <argn>)
{
<function body>
return <some value>;
}
17. Choose Build <Project name>.DLL from the VC++ IDE menu.
18. Fix any errors and repeat step 17.
19. 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.
20. 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 17).
21. 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