Creating a LIB or DLL
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
Dave,
Have you included this in your EXE PRG ?
DLL FUNCTION HBDLLSTRING2( cProc AS LPSTR, pItem1 AS LONG, pItem2 AS LONG ) AS LPSTR PASCAL LIB "dll2test.dll"
Is Test1() still working ?
Have you included this in your EXE PRG ?
DLL FUNCTION HBDLLSTRING2( cProc AS LPSTR, pItem1 AS LONG, pItem2 AS LONG ) AS LPSTR PASCAL LIB "dll2test.dll"
Is Test1() still working ?
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
Antonio,
Yes to both questions. My last maindll.c posted is correct my prior one may have had a problem.
I am making sure test1 is good as a control. Let me know if you need me to post any of my code.
Thanks
Yes to both questions. My last maindll.c posted is correct my prior one may have had a problem.
I am making sure test1 is good as a control. Let me know if you need me to post any of my code.
Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
Antonio,
I did and impdef on the dll
No hbdllstring
Here is what i have in the buildhd,bat
%bcdir%\bin\bcc32 -c -I%hdir%\include;%bcdir%\include -L%bcdir%\..\lib maindll.c
Thanks
I did and impdef on the dll
Code: Select all
LIBRARY DLL2TEST.DLL
EXPORTS
DllEntryPoint @1 ; DllEntryPoint
HBDLLENTRY @2 ; HBDLLENTRY
HBDLLENTRY1 @3 ; HBDLLENTRY1
HBDLLENTRY2 @4 ; HBDLLENTRY2
__DbgWndProc @6 ; __DbgWndProc
__WndProc @5 ; __WndProc
___CPPdebugHook @7 ; ___CPPdebugHook
No hbdllstring
Here is what i have in the buildhd,bat
%bcdir%\bin\bcc32 -c -I%hdir%\include;%bcdir%\include -L%bcdir%\..\lib maindll.c
Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
Dave,
HBDLLSTRING2 should be in the DEF file.
I guess maindll.obj is wrong. Or you have not properly rebuilt the DLL.
HBDLLSTRING2 should be in the DEF file.
I guess maindll.obj is wrong. Or you have not properly rebuilt the DLL.
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
Antonio,
Added _export after PASCAL now appears in def and displays message in dll.
Still no return value.
current code in maindll.c
Thanks
Added _export after PASCAL now appears in def and displays message in dll.
Still no return value.
current code in maindll.c
Code: Select all
HB_EXPORT char * PASCAL _export HBDLLSTRING2( char * cProcName, LONG pItem1, LONG pItem2 )
{
MessageBox( 0, "Inside ", "1", 0 );
hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem1, ( PHB_ITEM ) pItem2, 0 );
MessageBox( 0, hb_parc( -1 ), "2", 0 );
return hb_parc( -1 );
}
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
Dave,
Is this msg properly showing the text ?
MessageBox( 0, hb_parc( -1 ), "2", 0 );
Is this msg properly showing the text ?
MessageBox( 0, hb_parc( -1 ), "2", 0 );
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
Antonio,
No, the box 2 appears empty.
Thanks
No, the box 2 appears empty.
Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
Dave,
Is this MsgInfo() showing properly ?
Is this MsgInfo() showing properly ?
Code: Select all
function Test2( cMsg1, cMsg2 )
local cr:=chr(13)
cMsg1:=cMsg1+cr+"This is being added on in the DLL."
cMsg1:=cMsg1+cr+" So Far so good."
cMsg1:=cMsg1+cr+"Time to send this message"
cMsg1:=cMsg1+cr+"back the TESTDLL.EXE."
MsgInfo( cMsg1, cMsg2 )
return (cMsg1)
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
Antonio,
Yes since I added the _export after PASCAL.
Thanks
Yes since I added the _export after PASCAL.
Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
Dave,
Please try it this way:
Please try it this way:
Code: Select all
HB_EXPORT char * PASCAL _export HBDLLSTRING2( char * cProcName, LONG pItem1, LONG pItem2 )
{
PHB_ITEM pResult;
MessageBox( 0, "Inside ", "1", 0 );
pResult = hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem1, ( PHB_ITEM ) pItem2, 0 );
MessageBox( 0, hb_itemGetC( pResult ), "2", 0 );
return hb_itemGetC( pResult );
}
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
Antonio,
That works
Thanks
That works
Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Dave Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
Antonio,
Thank you very much for all your help.
My project is going very well and I very happy with what we have been able to do so far.
I would like to ask your advice on how best to apply the next changes to the program.
I am trying to have the DoSum return the value from the dll to the exe
In the EXE I will have:
function test3 in the testdll.prg
Call to DLL
In the maindll.c
In the dll2test.prg:
Thanks
Thank you very much for all your help.
My project is going very well and I very happy with what we have been able to do so far.
I would like to ask your advice on how best to apply the next changes to the program.
I am trying to have the DoSum return the value from the dll to the exe
In the EXE I will have:
function test3 in the testdll.prg
Code: Select all
************************** Test 3 DoSum
function test3(x,y)
local cr:=chr(13)
local hItem1 := ItemNew( x )
local hItem2 := ItemNew( y )
local rtnval :=0
rtnval:=HbDLLDoSum2( "DoSum", hItem1, hItem2 )
ItemRelease( hItem1 )
ItemRelease( hItem2 )
MsgInfo( str(rtnval)+"=Total"+cr+"OK! We are back to the EXE." )
return nil
Code: Select all
DLL FUNCTION HBDLLDoSUM2( cProc AS LPSTR, pItem1 AS LONG, pItem2 AS LONG ) AS LPSTR PASCAL LIB "dll2test.dll"
In the maindll.c
Code: Select all
HB_EXPORT char * PASCAL _export HBDLLDOSUM2( 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 );
}
Code: Select all
function Test3( x, y )
local z:=X+y
return (z)
Thanks
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: Creating a LIB or DLL
Dave,
This time you are going to generate a number (LONG). In case you plan to use decimals, then a different code is needed. Please review Harbour\source\vm\itemapi.c functions:
In the maindll.c
This time you are going to generate a number (LONG). In case you plan to use decimals, then a different code is needed. Please review Harbour\source\vm\itemapi.c functions:
Code: Select all
DLL FUNCTION HBDLLDoSUM2( cProc AS LPSTR, pItem1 AS LONG, pItem2 AS LONG ) AS LONG PASCAL LIB "dll2test.dll"
Code: Select all
HB_EXPORT LONG PASCAL _export HBDLLDOSUM2( 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 Zowasky
- Posts: 125
- Joined: Wed Oct 19, 2005 2:28 pm
- Location: Hudson Ohio
- Contact:
Re: Creating a LIB or DLL
Antonio,
I applied changes cannot get to MessageBox Point 2
I get a GPF send to microsoft crash.
code in maindll.c
code in exe
Code in dll
Thanks
I applied changes cannot get to MessageBox Point 2
I get a GPF send to microsoft crash.
code in maindll.c
Code: Select all
HB_EXPORT LONG PASCAL _export HBDLLDOSUM2( char * cProcName, LONG pItem1, LONG pItem2 )
{
PHB_ITEM pResult;
MessageBox( 0, "Point 1", "1", 0 );
pResult = hb_itemDoC( cProcName, 2, ( PHB_ITEM ) pItem1, ( PHB_ITEM ) pItem2, 0 );
MessageBox( 0, "Point 2", "2", 0 );
return hb_itemGetNL( pResult );
}
code in exe
Code: Select all
?HbDLLDoSum2( "TEST3",3, 2 )
Code: Select all
DLL FUNCTION HBDLLDOSUM2( cProc AS LPSTR, pItem1 AS LONG, pItem2 AS LONG ) AS LONG PASCAL LIB "dll2test.dll"
Code: Select all
function Test3( x, y )
local z:=X+y
return (z)
Dave Zowasky
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771
Com1 Software, Inc.
http://www.com1software.com
information@com1software.com
330 653-3771