Creating Dynamic Link Libraries

The steps involved in creating a DLL are very similar to those for creating standard Windows executable programs. The source code for a DLL is identical to the source code for any executable module. The following code segment shows the source code for a very simple DLL.

#include <windows.h>

// AddNumbers - This is a routine in a DLL that an application may call.

int AddNumbers( int n1, int n2 )
{
    return( n1 + n2 );
}

This is the same as any subroutine you might code for an ordinary application. The differences occur in the module definition file (.DEF). The linker uses the module definition file to provide information specific to the creation of DLLs. The following code segment illustrates a minimal module definition ...

Get Microsoft Windows 2000 API SuperBible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.