Startseite       Produkte       News       Bestellungen       Download       Support       Kontakt 
 

Zurück

Creating a simple DLL

To create a simple DLL to be called from HTBasic using Microsoft DevStudio 6.0:

  1. First create a new project
  2. From the file menu select New
  3. Select the Projects tab
  4. Highlight Win32 Dynamic-Link Library and type in the name of your new DLL in the Project Name field

  1. Choose OK
  2. Choose An empty DLL project and Finish on the next dialog screen
  3. Choose OK on the New Project Information Dialog

At this point a new project has been created with no source files in it. A C++ source file to hold our code now needs to be created.

  1. From the File menu, choose New
  2. Click on the Files tab and highlight C++ Source File
  3. Type in the name of the source file in the File name field
  4. Make sure the Add to project check box is checked

  1. Choose OK

A source file to place the C++ functions and subprograms in now exists.

Type the C++ source code into the file just created.

A DLL like any C++ project can consist of multiple source files that are compiled separately and then linked together. For simplicity this example uses only one source file.

A file which designates which labels will be visible outside of the DLL now needs to be created.

  1. From the File menu, choose New
  2. Select the Files tab, and highlight Text File
  3. In the File name field, specify the name of the file as the same name as the DLL with a .def extension
  4. Again, make sure that the Add to project check box is checked

  1. Choose OK

This file will list the labels that will be visible outside the DLL.

In the .def file just created type the word EXPORTS (all capital letters), and then on the next lines list the labels from the project that other programs, such as your HTBasic programs must be able to see.

Remember that C and C++ are case sensitive. The labels must be listed in the .def file exactly the same as they are declared.

Save this file and build the project by selecting the Build menu item Build <DLLname> or Rebuild All. A hot-key shortcut to build a project is F7. There is also an icon on the toolbar to build the project.

If the output window says “0 error(s), 0 warning(s)” then the DLL has been successfully created and is ready to be used by other programs such as HTBasic.

It is a good idea to write some documentation for your DLL. It should include a list of all the exported labels, what they are, and how to use them.

This documentation is vital for a user that may be using your DLL. It will also be useful if you ever have to remember what is in your DLL and the original source code is not available or too inconvenient to check.

The nicer and more detailed you make your documentation, the happier your users will be.

Problem Report | Tutorials | DLL Toolkit | Downloads | Faq