In this file, Marius Ganuci ( http://www.quickweb.ro ) gives a short 
introduction of how to use HIME.dll from C++.
Thanks Marius !

-----------------------------------------------

You have two ways of using the dll provided by the HIME distribution:
explicit linking and implicit linking the dll into your project.



Explicit linking
--------------
The classical approach on LoadLibrary / GetProcAddress / FreeLibrary

For Visual C++ is a little more complicated to create the lib file, but
can see how you can get it out of a simple dll file with no other files
http://support.microsoft.com/kb/q131313/. I personally found that to be
much too tricky to try so, for Visual C++ I have used explicit linking

//
//  Function definition
//
typedef long (*HI_PUTREG)(char* val, long* reg);
HI_PUTREG hiPutReg;

//
//  Function loading
//
hiPutRegAdd = (HI_PUTREGADD)GetProcAddress(dllInstance, "HI_PUTREGADD");
ASSERT(hiPutRegAdd != NULL);


Example of usage:

CString clearText
char* buffer = clearText.GetBuffer();
//
//  bufSize is a class long pointer field which is reused each time
after setting its value to the size you need to specify
//
*bufSize = clearText.GetLength()
hiOperationResult = hiPutRegAdd((long*)(&buffer), bufSize, reg1);
ASSERT(hiOperationResult == 0);

Note the second parameter which is suppose to be a pointer and not an
integer value; I use a single variable called bufSize and each time I
need to call the function, I store at that address the length of the
buffer I need to store


Getting values out of registers
int size = hiRegGetLen(reg5);
CString* ret = new CString((char*)hiGetReg(reg5), size);

Notice the way the CString is constructed, also specifying the size as
binary values may be involved which may prevent the CString correct
initialization. In order to use the result as a char* you will also need
the size of the registry.


Note for Visual C++ developers: make sure you set your project
properties to use the __stdcall (/Gz )calls otherwise you will get
corrupted program heap errors when loading the dll with LoadLibrary /
AfxLoadLibrary. (Configuration Properties / C/C++ / Advanced -> Calling
Convension.



Implicit linking
--------------
For this you need to include the lib file into your project and the h
file. Usually the lib file is delivered along by the dll maker, but you
can make your own lib file depending on the target technology:
- for Borland C++ users, you can make your own lib file by using
ImportLibrary utility (implib) which comes with the IDE. The h file was
created by hand and the thing to be noted here is the use of AnsiString
as argument for HI_PUTREG function as well as the use of __stdcall in
function definition (this was already in the documentation, but this is
how it applies).

Another key point here is that in order to store data into registers,
you will need to provide the pointer to location number and not the
actual number

//
//  Init all the registers you may use
//
long* reg1 = (long*)malloc(sizeof(long));
// assert(reg1 != NULL)
*reg1 = 1;

AnsiString text;
int hiOperationResult = HI_PUTREG(clearText, reg1);

//////

Getting data from register using AnsiString

char* ret = (char*)malloc(sizeof(char) * HI_REGGETLEN(reg1));
ret = (char*)HI_GETREG(reg5);


Borland users: notice the attached definition h / lib file attached
(normally you would call them hime.h / hime.lib)




Best Regards,
Marius
