Previous Section
5. Full sources
| Contents | Next Section
7. How to use HIDE to write libraries

6. How to use HIDE to code a DLL



Create a New Project:

Menu: Project > New Project
Type "DemoDLL" in the "Project Name" field.Select the DLL radio-button in the Project Type group.
click OK

This will create a new project with two active files:
1. DemoDLL.hla
2. DemoDLL.def

The DemoDLL.def file will be used for exports.

DLL's in HLA are implemented as HLA units.

Write the sample DLL program.

DemoDLL.hla
unit DemoDLLunit;
#include("w.hhf")

// if HLA standard library code is used, uncomment
// the lines below
//label
// shorthwExcept__hla_; @external; //procedure HWexcept; @external( "HWexcept__hla_" ); //procedure HWexcept; //begin HWexcept; // jmp shorthwExcept__hla_; //end HWexcept; procedure DemoDLL ( instance:dword; reason:dword; reserved:dword ); @stdcall; @external; procedure DllFunc; @stdcall; @external; procedure DemoDLL( instance:dword; reason:dword; reserved:dword ); @nodisplay; begin DemoDLL; mov( true, eax ); end DemoDLL; procedure DllFunc; @nodisplay; begin DllFunc; w.MessageBox(NULL,"Hello From DLL","From DemoDLL",w.MB_OK); end DllFunc; end DemoDLLunit;

Once the program is written, fill out the DemoDLL.def with the appropriate Exports:

File: "DemoDLL.def"

EXPORTS
	DemoDLL
	DllFunc



That's it, now hit F5 to build.

This will create 3 files: DemoDLL.dll, DemoDLL.lib and DemoDLL.exp

To test out the DLL, Let's create a test project: call the project DemoDLLTest.hla, and choose Windows Program copy the DemoDLL.lib and DemoDLL.dll into the DemoDLLTest folder


DemoDLLTest.hla
program DemoDLLTest;
#include("stdlib.hhf")

procedure DllFunc;	 @external;

begin DemoDLLTest;
	
	call DllFunc;
	
end DemoDLLTest;

Before compiling, we need to add DemoDLL.lib to the libraries list:
Menu: Project > Add to Link List Double click on DemoDLL.lib Make: Build