Call a Dll from an Exe

Call a Dll from an Exe

Postby don lowenstein » Thu Jul 03, 2008 5:26 pm

I have setup a simple exe and dll. I am attempting to dynamicly call a dll from an exe. In my simple example I am calling the dll and execution is passing to the Dll no problem. However, when the dll returns, execution ends, and does NOT resume in the exe as I would suspect.

I am using the fwh\samples\tutor01.prg as the dll example, and I am using the testdll.prg as the exe.

My environment is xharbour 0.99.51 - fwx v2.6 using borland compiler.

Can anyone point me in the proper direction on this issue?
Any help is greatly appreciated.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Postby Antonio Linares » Thu Jul 03, 2008 8:18 pm

Don,

What build...bat are you using to build the DLL ?

Is it a pcode only DLL or a self contained DLL ?
regards, saludos

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

Postby don lowenstein » Thu Jul 03, 2008 8:29 pm

What build...bat are you using to build the DLL ?

I modified the buildhd.bat in the fivewin samples to adher to my environment - did not change any compile / link switches.

I am attempting to create a self contained dll.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Postby Antonio Linares » Thu Jul 03, 2008 8:43 pm

Don,

Here it is working fine using FWH 8.06 and current xHarbour provided with it. Here you have the EXE and the DLL, so you can test it yourself:

http://www.mediafire.com/?hwwlfmibi1u
regards, saludos

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

Postby don lowenstein » Thu Jul 03, 2008 9:22 pm

Antonio - Thank you for the quick response and sample.

This example works great :D

Can you send the source - and scripts used to make/link?

This is exactly what I am atempting, however - my exe never gets control back after the dll return.

Thank you for your help
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Postby Antonio Linares » Thu Jul 03, 2008 11:38 pm

Don,

I used the same sources as you: the ones from fwh\samples without modifying them:
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   HbDLLEntry( "MAIN" )
   MsgInfo( "ok from EXE" )

return nil

DLL FUNCTION HBDLLENTRY( cProc AS LPSTR ) AS LONG PASCAL LIB "Tutor01.dll"

I guess the differences come from the different xHarbour build that we are using. I suggest you to upgrade to the most recent FWH and xHarbour.
regards, saludos

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

Postby don lowenstein » Mon Jul 07, 2008 4:01 pm

Antonio - Thank you for the assistance.

The most current xHarbour we have is v1.0 - with FWH v7

What versions are you using?

I also noticed in the scripts a reference to maindll.obj
I do not have this module - what is it?

Thanks again for all your help
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Postby Antonio Linares » Mon Jul 07, 2008 5:59 pm

Don,

We are using current FWH 8.06 with the xHarbour (June 2008) published on these forums in http://fivetechsoft.com/forums/viewtopic.php?t=2486

maindll.obj is a Harbour/xHarbour module, that it is not included by default in the setup file. Here you have it:
http://rapidshare.com/files/123510556/maindll.obj.html
regards, saludos

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

Re: Call a Dll from an Exe

Postby Romeo » Tue Mar 16, 2010 6:16 pm

Hi Antonio i have the same problem with tutor01.prg and testdll.prg using the buildhd.bat.

I DONT HAVE THE FILE NAMED MIANDLL.OBJ, SO I REM THE LINE BUT....

It runs the DLL but does not cam back in the EXE file.

Any solution for me ?

FWH 8.1 HARBOUR 1.01 (build. 9361)
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: Call a Dll from an Exe

Postby Romeo » Tue Mar 23, 2010 6:06 pm

Hi to all,
can sameone very kkkiiiinnnnddddlllyyyy pass me the maindll.obj ?

Tks
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: Call a Dll from an Exe

Postby Antonio Linares » Thu Mar 25, 2010 10:08 am

regards, saludos

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

Re: Call a Dll from an Exe

Postby Antonio Linares » Thu Mar 25, 2010 10:14 am

Romeo,

I think it is going to be much more convenient and easier for you if you upgrade to the most recent Harbour version and also if you use HRB files instead of DLL files. There have been so many changes in Harbour.
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Silvio.Falconi and 106 guests