Page 9 of 10
Re: Creating a LIB or DLL
Posted: Thu Apr 09, 2009 6:56 pm
by Dave Zowasky
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
************************** 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
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
function Test1( cMsg1, cMsg2 )
MsgInfo( cMsg1, cMsg2 )
return nil
Thanks
Re: Creating a LIB or DLL
Posted: Thu Apr 09, 2009 7:18 pm
by Antonio Linares
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"
Re: Creating a LIB or DLL
Posted: Thu Apr 09, 2009 8:03 pm
by Dave Zowasky
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
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
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
Re: Creating a LIB or DLL
Posted: Thu Apr 09, 2009 10:33 pm
by Antonio Linares
Dave,
You missed two "*" here:
HB_EXPORT char * PASCAL _export HBDLLSTRING4( char * cProcName, char * cText1, char * cText2 )
Re: Creating a LIB or DLL
Posted: Thu Apr 09, 2009 10:50 pm
by Dave Zowasky
Antonio,
Works Great Thanks
Re: Creating a LIB or DLL
Posted: Mon Apr 13, 2009 3:00 am
by Dave Zowasky
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
Re: Creating a LIB or DLL
Posted: Mon Apr 13, 2009 10:54 am
by Antonio Linares
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.
Re: Creating a LIB or DLL
Posted: Tue Apr 14, 2009 10:34 pm
by Dave Zowasky
Antonio,
I have my C++ DLL calls working very well
Question is this possible?
Code: Select all | Expand
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
Re: Creating a LIB or DLL
Posted: Tue Apr 14, 2009 11:41 pm
by Antonio Linares
Dave,
> I have my C++ DLL calls working very well
very good
pResult = hb_itemDoC( cProcName, 3, pItem1, pItem2, pItem3, 0 );
Re: Creating a LIB or DLL
Posted: Wed Apr 15, 2009 10:08 pm
by Dave Zowasky
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
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
************************** 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
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
********************************** 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
Re: Creating a LIB or DLL
Posted: Wed Apr 15, 2009 10:21 pm
by Antonio Linares
Dave,
This is wrong:
Code: Select all | Expand
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
DLL FUNCTION HBDLLSTRING5( cProc AS LPSTR, cText1 AS LPSTR, cText2 AS LPSTR, cText3 AS LPSTR ) AS LPSTR PASCAL LIB "dll2test.dll"
Re: Creating a LIB or DLL
Posted: Wed Apr 15, 2009 10:52 pm
by Dave Zowasky
Antonio,
Works good, I see what to clean up.
Thanks
Re: Creating a LIB or DLL
Posted: Mon Sep 29, 2014 2:15 pm
by asimoes
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
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
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 );
}
Re: Creating a LIB or DLL
Posted: Tue Sep 30, 2014 8:41 am
by Antonio Linares
Please carefully review this post:
viewtopic.php?p=66183#p66183
Re: Creating a LIB or DLL
Posted: Tue Oct 07, 2014 6:29 pm
by asimoes
Hola Antonio,
Gracias por el servicio rápido.
Yo no podía entender cómo aplicar el ejemplo del mensaje que publiqué el problema.