Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

Runtime dynamic linking using .dli files

In Ultimate++ you can use .dli file to automatize generating .dll wrapper objects. To create such object you have to provide ".dli" file with content like (actual example is for Lotus Notes client .dll):

 

FN(WORD,   OSLoadString, (HMODULE hModule, STATUS StringCode, char *retBuffer, WORD BufferLength))

FN(WORD,   OSTranslate, (WORD TranslateMode, char far *In, WORD InLength, char far *Out, WORD OutLength))

FN(STATUS, NotesInitExtended, (int argc, char  **argv))

FN(STATUS, OSPathNetConstruct, (char *PortName, char *ServerName, char far *FileName, char *retPathName))

FN(STATUS, NSFDbOpen,  (char far *PathName, DBHANDLE far *rethDB))

FN(STATUS, NSFDbClose,  (DBHANDLE hDB))

...........

 

- basically, this is somewhat "reparsed" header file for .dll. Then place

 

#define DLLFILENAME "nnotes.dll"

#define DLIMODULE   NOTES

#define DLIHEADER   <notes/notes.dli>

#define DLLCALL     LNPUBLIC

#include <Core/dli_header.h>

 

to common header file and

 

#define DLLFILENAME "nnotes.dll"

#define DLIMODULE   NOTES

#define DLIHEADER   <notes/notes.dli>

#define DLLCALL     LNPUBLIC

#include <Core/dli_source.h>

 

to some .cpp file or, if you need that .dll just in single .cpp file, you can use

 

#define DLLFILENAME "nnotes.dll"

#define DLIMODULE   NOTES

#define DLIHEADER   <notes/notes.dli>

#define DLLCALL     LNPUBLIC

#include <Core/dli.h>

 

in .cpp (this is equivalent of placing both above variants to .cpp).

 

This creates global function NOTES() returning the object instance that has all .dll functions described in .dli file defined as its methods. Moreover, it has operator bool that can be used to test whether .dll is present:

 

char h[256];

if(NOTES())

    NOTES().OSLoadString(GetModuleHandle(NULL), ERR(nError), h, 255);

 

 

Last edit by novo on 12/13/2012. Do you want to contribute?. T++