How to make a DLL

User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Post by Rafael Clemente »

Antonio:
You could send just one string using a format similar like this:
Yes; that's what I was planning to do anyway
To do it, just include this function in your DLL:
Compiling with buildhd.bat I get an error:

Error E2141 dlltest 41: Declaration syntax error
*** 1 errors in Compile ***

just after #include <hbapiitm.h>. However, the DLL gets built. Is that normal?

Rafael
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rafael,

Please add as the third include:
#include <windows.h>
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Post by Rafael Clemente »

Antonio:
It's compiling Ok now. Many thanks for your fast answer. I'll try it with VB and I'll let you know the results...
Rafael
User avatar
Rafael Clemente
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Post by Rafael Clemente »

Antonio has suggested a way to make my DLL accesible from Visual Basic that just completes the receipt to make DLLs callables from another language. Just add the following to the .prg:

Code: Select all

long _export pascal TEST( char * cProcName, char * cParam )
{
   PHB_ITEM pItem = hb_itemPutC( NULL, cParam );

   hb_itemDoC( cProcName, 1, ( PHB_ITEM ) pItem, 0 );
   hb_itemRelease( pItem );

   return 0;
} 

and declare the DLL in VB as follows:

Declare Function TEST Lib "C:\Path\MyDll" (ByVal cProcName As String, ByVal cParam As String) As Long
Then, from VB5 just call the function as always:

Code: Select all

n = TEST("TEST", "My_parameter")
I'm sure many people will find this info valuable. Thanks a lot, Antonio!

Rafael
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rafael,

Glad to know it is working :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply