How to make a DLL

Postby Rafael Clemente » Mon Oct 08, 2007 8:26 am

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
Rafael Clemente
 
Posts: 365
Joined: Sat Oct 08, 2005 7:59 pm
Location: Barcelona, Spain

Postby Antonio Linares » Mon Oct 08, 2007 8:30 am

Rafael,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41462
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Rafael Clemente » Mon Oct 08, 2007 8:33 am

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

Postby Rafael Clemente » Wed Oct 10, 2007 7:03 pm

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  Expand view
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  Expand view
n = TEST("TEST", "My_parameter")


I'm sure many people will find this info valuable. Thanks a lot, Antonio!

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

Postby Antonio Linares » Wed Oct 10, 2007 7:07 pm

Rafael,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41462
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 131 guests