Dave,
The code seems to be ok
Dave,
The code seems to be ok
function test4()
local cr:=chr(13)
local hItem1 := ItemNew( "The Message is : Test to return a numeric value" )
local hItem2 := ItemNew( "This is the Title for the Harbour DLL" )
?HbDLLstring3( "TEST4", hItem1, hItem2 )
ItemRelease( hItem1 )
ItemRelease( hItem2 )
MsgInfo( "OK! We are back to the EXE." )
return nilHB_EXPORT char * PASCAL _export HBDLLSTRING3( char * cProcName, LONG pItem1, LONG pItem2 )
{
PHB_ITEM pResult;
pResult = hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem1, ( PHB_ITEM ) pItem2, 0 );
return hb_itemGetC( pResult );
}function Test4( cMsg1, cMsg2 )
local z:=99
MsgInfo( cMsg1, cMsg2 )
return (z)Dave,
> I noticed hb_itemGetNL( pResult ); in test3 however it causes error in compile when used in test4
What error do you get ?
Antonio,
Error E2349 maindll.c 130: Nonportable pointer conversion in function HBDLLSTRING3
Thanks
Dave,
> Error E2349 maindll.c 130: Nonportable pointer conversion in function HBDLLSTRING3
Please copy line 130 of your maindll.c here, thanks
HB_EXPORT char * PASCAL _export HBDLLSTRING3( char * cProcName, LONG pItem1, LONG pItem2 )
{
PHB_ITEM pResult;
pResult = hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem1, ( PHB_ITEM ) pItem2, 0 );
return hb_itemGetC( pResult );
}HB_EXPORT char * PASCAL _export HBDLLSTRING3( char * cProcName, LONG pItem1, LONG pItem2 )
{
PHB_ITEM pResult;
pResult = hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem1, ( PHB_ITEM ) pItem2, 0 );
return hb_itemGetNL( pResult );
}Dave,
When you write:
HB_EXPORT char * PASCAL ...
it means that the C function is going to return a char * (pointer to a char), that is a string, and hb_itemGetC( pResult ) returns a char *, so they match.
But when you use hb_itemGetNL( pResult ) then you return a number (LONG) and the compiler complains as there is no match with the specified returned value.
So if you use hb_itemGetNL( pResult ) then you need to declare the function this way:
HB_EXPORT LONG PASCAL ...
************************** Test 5 Hello World Back
function test5()
********
local cr:=chr(13)
local hItem1 :="test"
local hItem2 :="test2"
local dllhan:=loadlibrary("dll2test.dll")
local rtnitem:="Return Value not set yet."
local zzz
********
zzz:=getprocaddress(dllhan,"HBDLLSTRING2",.t.,4,4,9,9)
rtnitem=calldll(zzz,1,"testa","testa")
MsgInfo( rtnitem+cr+"OK! We are back to the EXE." )
return nil#pragma BEGINDUMP
#include <hbapi.h>
#include <hbapiitm.h>
HB_FUNC( ITEMNEW )
{
hb_retnl( ( ULONG ) hb_itemNew( hb_param( 1, HB_IT_ANY ) ) );
}
HB_FUNC( ITEMRELEASE )
{
hb_retl( hb_itemRelease( ( PHB_ITEM ) hb_parnl( 1 ) ) );
}
#pragma ENDDUMPDave,
Please try to use:
DLL FUNCTION ...
instead of:
zzz:=getprocaddress(dllhan,"HBDLLSTRING2",.t.,4,4,9,9)
rtnitem=calldll(zzz,1,"testa","testa")
to be sure that you are using the right params
Antonio,
I was looking at Visual C++ to replace my BCC55
http://www.microsoft.com/express/download/#webInstall
Is it possible and will I need a new version of Harbour?
I saw buildhm.bat. Wil that compile be compatibel with Visual C++ 2008?
Thanks
Dave,
I won't recommend you to switch now to MSVC, in the middle of your DLL development.
First you should complete your development using your current tools and once it is working as expected, then it would be fine to migrate to MSVC.
Just my advise. Obviously you are free to do as you want ![]()
Dave,
You have not answered my question regarding:
zzz:=getprocaddress(dllhan,"HBDLLSTRING2",.t.,4,4,9,9)
rtnitem=calldll(zzz,1,"testa","testa")
What DLL FUNCTION ... sentence were you using ? Why aren't you using it now ?
Antonio,
Regarding the MSVC your advice to stay focused on the current development is most graciously appreciated.
I was looking at what all the MS Visual Studio Express Editions and got excited.
My main reason in the shift in my code was because we have many calls like that in our production systems. Also I was
using my old FWH compiles to build my exe, add there is not support for
ItemNew() and ItemRelease( ) in the older version.
This was a production/update/implementation issue to us here.
To get back on track, I will update the batch file that I am using to make my test panel exe so that it is on the
latest version of FWH and using the DLL FUNCTION.
Thanks ![]()
#include <windows.h>
#include <stdio.h>
int __declspec(dllimport) WINAPI HBDLLSTRING2( char * cProcName, LONG pItem1, LONG pItem2 );
int main()
{
char xdata;
char ydata;
printf("Test2 HBDLLString2\n");
printf("The sum of 4 + 7 is %d\n", HBDLLSTRING2("test4",xdata,ydata));
return 0;
}
#pragma argsused
BOOL WINAPI DllEntryPoint(HINSTANCE h, DWORD d, LPVOID p)
{
return TRUE;
}
int __declspec(dllexport) WINAPI HBDLLSTRING2( char * cProcName, LONG pItem1, LONG pItem2 )
{
char xdata;
return (xdata);
}.autodepend
testdll.exe : testdll.c
bcc32 -WCR -Ih:\bcc55\include -Lh:\bcc55\lib testdll.cLONG PASCAL HBDLLENTRY2( char * cProcName, char * cText1, char * cText2 )
{
PHB_ITEM pItem1 = hb_itemPutC( NULL, cText1 );
PHB_ITEM pItem2 = hb_itemPutC( NULL, cText2 );
hb_itemDoC( cProcName, 2, pItem1, pItem2, 0 );
hb_itemRelease( pItem1 );
hb_itemRelease( pItem2 );
return 0;
}