Creating a Dynamic Link Library

A DLL contains one or more exported Classes, Subs, or Functions that may be called by applications or other DLLs. A DLL may also contain any number of private Subs or Functions that can only be called from within the library. Creating a DLL with PowerBASIC is straightforward. Below are the steps to follow to convert parts of a Visual Basic program to a DLL.

Step 1: | The first step is to identify the sections of your application that are used in multiple programs, or in the case of Visual Basic, Subs and Functions that you need to execute faster.
Step 2: | Save those Subs and Functions as text, and change the file extension to .BAS. This will become the source module that will be compiled into a DLL with PowerBASIC. You could also create the source file from scratch, if you so wish.
Step 3: | Launch PBEDIT.EXE (the PowerBASIC IDE) and add the EXPORT keyword to any Sub or Function in the DLL source code (that you wish to be made accessible to external applications). Add #COMPILE DLL to the top of the source code file, and make any other changes to your .BAS source module. See the SUB/END SUB and FUNCTION/END FUNCTION topics for more information on the exact syntax.
Step 4: | Click the compile button on the PowerBASIC IDE toolbar.

Any compile-time error s will be flagged at this point. Repeat steps 3 to 4 above until no more errors are reported. You are then ready to start testing and debugging your DLL. Debugging is done using the PowerBASIC symbolic Debugger built into the PowerBASIC IDE (PBEDIT.EXE). See the section on Debugging for more information.

See Also

What is a Dll?

Private and Exported Procedures

Dll example

LibMain

What is an object, anyway?

Just what is COM?

What is a COM component?