Creating a LIB or DLL

Re: Creating a LIB or DLL

Postby Dave Zowasky » Thu Apr 09, 2009 6:56 pm

Antonio,

Some progress. I am able to get to entry point 1
My msginfo from test1 in the dll is displayed, however there is no data being displayed in it.

Code: Select all  Expand view  RUN

************************** Test 5 Hello World 2
function test5()
   local cr:=chr(13)
   HbDLLEntry3( "TEST1", "TESTA", "testb" )
   MsgInfo( "OK! We are back to the EXE." )
return nil
 


In my maindll.c
Code: Select all  Expand view  RUN

LONG PASCAL _export HBDLLENTRY3( char * cProcName, char * cText1, char * cText2 )
{
   PHB_ITEM pItem1 = hb_itemPutC( NULL, cText1 );
   PHB_ITEM pItem2 = hb_itemPutC( NULL, cText2 );
   MessageBox( 0, "Point 1", "1", 0 );
   hb_itemDoC( cProcName, 2, pItem1, pItem2, 0 );

   hb_itemRelease( pItem1 );
   hb_itemRelease( pItem2 );

   return 0;
}



Code in dll2test.prg
Code: Select all  Expand view  RUN
function Test1( cMsg1, cMsg2 )

   MsgInfo( cMsg1, cMsg2 )

return nil
 


Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Antonio Linares » Thu Apr 09, 2009 7:18 pm

Dave,

Have you declared HBDLLENTRY3() this way ?

DLL FUNCTION HBDLLENTRY3( cProc AS LPSTR, cText1 AS LPSTR, cText2 AS LPSTR ) AS LPSTR PASCAL LIB "dll2test.dll"
regards, saludos

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

Re: Creating a LIB or DLL

Postby Dave Zowasky » Thu Apr 09, 2009 8:03 pm

Antonio,

I had tried it that way and must have had it wrong. I cut and paste yours and it works great :)

I have been on to next the step.

I am having a problem with my dll compile with this code

Code: Select all  Expand view  RUN
HB_EXPORT char * PASCAL _export HBDLLSTRING4( char * cProcName, char cText1, char cText2 )
{
   PHB_ITEM pResult;  
   PHB_ITEM pItem1 = hb_itemPutC( NULL, cText1 );
   PHB_ITEM pItem2 = hb_itemPutC( NULL, cText2 );
   pResult = hb_itemDoC( cProcName, 2, pItem1, pItem2, 0 );
   hb_itemRelease( pItem1 );
   hb_itemRelease( pItem2 );
   return hb_itemGetC( pResult );
}

 


I get error

Code: Select all  Expand view  RUN
Error E2342 maindll.c 149: Type mismatch in parameter 'szText' (wanted 'const signed char *', got 'int') in function HBDLLSTRING4
Error E2342 maindll.c 150: Type mismatch in parameter 'szText' (wanted 'const signed char *', got 'int') in function HBDLLSTRING4
Warning W8057 maindll.c 155: Parameter 'cText1' is never used in function HBDLLSTRING4
Warning W8057 maindll.c 155: Parameter 'cText2' is never used in function HBDLLSTRING4
*** 2 errors in Compile ***


Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Antonio Linares » Thu Apr 09, 2009 10:33 pm

Dave,

You missed two "*" here:

HB_EXPORT char * PASCAL _export HBDLLSTRING4( char * cProcName, char * cText1, char * cText2 )
regards, saludos

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

Re: Creating a LIB or DLL

Postby Dave Zowasky » Thu Apr 09, 2009 10:50 pm

Antonio,

Works Great Thanks :)
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Dave Zowasky » Mon Apr 13, 2009 3:00 am

Antonio,

I started testing my dll and I have had some success with other programs. I am able to get calls to the DLL working using mg.
In my test to return data to the calling program I am getting nothing back to the mg program, however calling DLL `works very good.

I am trying to run some tests using VB and I am running into problems. Should I be able to call my DLL from VB at this point?

Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Antonio Linares » Mon Apr 13, 2009 10:54 am

Dave,

> Should I be able to call my DLL from VB at this point?

yes, you should be able to do it.

We don't know anything about mg, sorry.
regards, saludos

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

Re: Creating a LIB or DLL

Postby Dave Zowasky » Tue Apr 14, 2009 10:34 pm

Antonio,

I have my C++ DLL calls working very well :)

Question is this possible?

Code: Select all  Expand view  RUN
HB_EXPORT char * PASCAL _export HBDLLSTRING3( char * cProcName, char * cText1, char * cText2, char * cText3 )
{
   PHB_ITEM pResult;  
   PHB_ITEM pItem1 = hb_itemPutC( NULL, cText1 );
   PHB_ITEM pItem2 = hb_itemPutC( NULL, cText2 );
   PHB_ITEM pItem3 = hb_itemPutC( NULL, cText3 );

** if possible what here?
   pResult = hb_itemDoC( cProcName, 2, pItem1, pItem2, 0 );


   hb_itemRelease( pItem1 );
   hb_itemRelease( pItem2 );
   hb_itemRelease( pItem3 );
      return hb_itemGetC( pResult );
}
 


Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Antonio Linares » Tue Apr 14, 2009 11:41 pm

Dave,

> I have my C++ DLL calls working very well

very good :-)

pResult = hb_itemDoC( cProcName, 3, pItem1, pItem2, pItem3, 0 );
regards, saludos

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

Re: Creating a LIB or DLL

Postby Dave Zowasky » Wed Apr 15, 2009 10:08 pm

Antonio,

I still have a problem when I go to three parameters.

When I call the dll from the exe, the parm data for all three fields is blank

return value is good


Code: Select all  Expand view  RUN
HB_EXPORT char * PASCAL _export HBDLLSTRING5( char * cProcName, char * cText1, char * cText2, char * cText3  )
{
   PHB_ITEM pResult;  
   PHB_ITEM pItem1 = hb_itemPutC( NULL, cText1 );
   PHB_ITEM pItem2 = hb_itemPutC( NULL, cText2 );
   PHB_ITEM pItem3 = hb_itemPutC( NULL, cText3 );
   MessageBox( 0, "Point  in hbdllstring5", "1", 0 );
   pResult = hb_itemDoC( cProcName, 3, pItem1, pItem2, pItem3, 0 );
   hb_itemRelease( pItem1 );
   hb_itemRelease( pItem2 );
   hb_itemRelease( pItem3 );
   return hb_itemGetC( pResult );
}

 


in exe
Code: Select all  Expand view  RUN

************************** Test 7 Hello World 3
function test7()
   local cr:=chr(13)

************************** for return string from dll
   local rtnitem:="Return Value not set yet."
   local item1:="Here We are"
   local item2:="Top of Box"
   local item3:="TItem 3"
   rtnitem:=HbDLLstring5( "TEST5", Item1, Item2, Item3  )
   MsgInfo( rtnitem+cr+"OK! We are back to the EXE." )
return nil
 

in exe
Code: Select all  Expand view  RUN
DLL FUNCTION HBDLLSTRING5( cProc AS LPSTR, cText1 AS LONG, cText2 AS LONG, cText3 AS LONG  ) AS LPSTR PASCAL LIB "dll2test.dll"



In dll
Code: Select all  Expand view  RUN

********************************** Test 2 Hello World Back
function Test5( cMsg1, cMsg2, cMsg3 )
local cr:=chr(13)

   cMsg1:=cMsg1+"This is being added on in the DLL."
   cMsg1:=cMsg1+"     So Far so good."

   MsgInfo( cMsg1, cMsg2 )

   MsgInfo( cMsg3, "AAA" )



return (cMsg1)
 


Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby Antonio Linares » Wed Apr 15, 2009 10:21 pm

Dave,

This is wrong:
Code: Select all  Expand view  RUN

DLL FUNCTION HBDLLSTRING5( cProc AS LPSTR, cText1 AS LONG, cText2 AS LONG, cText3 AS LONG  ) AS LPSTR PASCAL LIB "dll2test.dll"
 


It has to be this way:
Code: Select all  Expand view  RUN

DLL FUNCTION HBDLLSTRING5( cProc AS LPSTR, cText1 AS LPSTR, cText2 AS LPSTR, cText3 AS LPSTR  ) AS LPSTR PASCAL LIB "dll2test.dll"
 
regards, saludos

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

Re: Creating a LIB or DLL

Postby Dave Zowasky » Wed Apr 15, 2009 10:52 pm

Antonio,

Works good, I see what to clean up.

Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
User avatar
Dave Zowasky
 
Posts: 125
Joined: Wed Oct 19, 2005 2:28 pm
Location: Hudson Ohio

Re: Creating a LIB or DLL

Postby asimoes » Mon Sep 29, 2014 2:15 pm

Amigos,
Con base en este ejemplo cómo pasar una variable por referencia, por ejemplo:

cMsg1: = ""
cMsg2: = ""
cMsg3: = ""

Test5(@cMsg1, @cMsg2, @cMsg3)

Hasta ahora no recibo éxito hasta llamar
disculpen mi español es el traductor de google
Code: Select all  Expand view  RUN

hLib := hb_libLoad( "MinhaDll.dll" )
c:=""
x:=hb_DynCall( { "HBDLLSTRING5", hLib, hb_bitOr( HB_DYN_CTYPE_CHAR_PTR , HB_DYN_CALLCONV_STDCALL )  },"Test5", @c, "Top of Box", "Item 3" )
hb_libFree( hLib )
 

Code: Select all  Expand view  RUN

function Test5( cMsg1, cMsg2, cMsg3 )
local cr:=chr(13)

   cMsg1:=cMsg1+"This is being added on in the DLL."
   cMsg1:=cMsg1+"     So Far so good."
   
   cMsg2:="Outro valor"
   cMsg3:="Outro valor"
   
   MsgInfo( cMsg1, cMsg2 )

   MsgInfo( cMsg3, "AAA" )



return (cMsg1)

HB_EXPORT char * PASCAL _export HBDLLSTRING5( char * cProcName, char * cText1, char * cText2, char * cText3  )
{
   PHB_ITEM pResult;  
   PHB_ITEM pItem1 = hb_itemPutC( NULL, cText1 );
   PHB_ITEM pItem2 = hb_itemPutC( NULL, cText2 );
   PHB_ITEM pItem3 = hb_itemPutC( NULL, cText3 );
   MessageBox( 0, "Point  in hbdllstring5", "1", 0 );
   pResult = hb_itemDoC( cProcName, 3, pItem1, pItem2, pItem3, 0 );
   hb_itemRelease( pItem1 );
   hb_itemRelease( pItem2 );
   hb_itemRelease( pItem3 );
   return hb_itemGetC( pResult );
}
 
asimoes
 
Posts: 5
Joined: Mon Sep 29, 2014 10:58 am

Re: Creating a LIB or DLL

Postby Antonio Linares » Tue Sep 30, 2014 8:41 am

Please carefully review this post:

viewtopic.php?p=66183#p66183
regards, saludos

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

Re: Creating a LIB or DLL

Postby asimoes » Tue Oct 07, 2014 6:29 pm

Hola Antonio,
Gracias por el servicio rápido.
Yo no podía entender cómo aplicar el ejemplo del mensaje que publiqué el problema.
asimoes
 
Posts: 5
Joined: Mon Sep 29, 2014 10:58 am

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 111 guests