Tests

DLL module with a class

A module built with --shared that defines a class, used by the test DllLoad.prg.

Description

ModPoint() returns an object of the class DllPoint. Once the class is registered, ModuleUnload() refuses to free the module, because the methods of the class are code of the DLL. Build it with xdev --shared DllClass.prg.

Example

dll/DllClass.prg
CREATE CLASS DllPoint

   DATA x INIT 0
   DATA y INIT 0

   METHOD New( nX, nY )
   METHOD Sum()

ENDCLASS

METHOD New( nX, nY ) CLASS DllPoint

   ::x := nX
   ::y := nY

RETURN Self

METHOD Sum() CLASS DllPoint
RETURN ::x + ::y

// An object of the class of the module
FUNCTION ModPoint( nX, nY )
RETURN DllPoint():New( nX, nY )

Output