Prepare the Win32 DLL for Use

OverviewDetails

To prepare the DLL for use

  1. On the Project menu, point to Add to Project, then click Files to add your source code files to the project.

  2. If needed, add a function called DllMain and add the initialization and termination code for the DLL to this function.

  3. Make sure you have exported the entry points to your DLL by using either the __declspec(dllexport) keyword or by listing the functions in the DLL’s .DEF file.

  4. Prepare a header file that includes the programs using your DLL. This header file should contain the declarations of the appropriate functions. When the header file is compiled for a DLL, use the __declspec(dllexport) keyword to export from the DLL. When the header file is compiled for a program that uses the DLL, use the declspec(dllimport) keyword.

  5. If your DLL uses __declspec(dllexport) or a .DEF file, an import library will be created automatically. In other situtations you will need to prepare an import library for your programs to link with by ensuring that the /IMPLIB linker switch is set when building your DLL.

  6. Build the DLL.

What do you want to know more about?