FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Call a Dll from an Exe
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM

Call a Dll from an Exe

Posted: Thu Jul 03, 2008 05: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Call a Dll from an Exe

Posted: Thu Jul 03, 2008 08: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
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM

Call a Dll from an Exe

Posted: Thu Jul 03, 2008 08: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Call a Dll from an Exe

Posted: Thu Jul 03, 2008 08: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
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM

Call a Dll from an Exe

Posted: Thu Jul 03, 2008 09: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Call a Dll from an Exe

Posted: Thu Jul 03, 2008 11:38 PM
Don,

I used the same sources as you: the ones from fwh\samples without modifying them:
#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
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM

Call a Dll from an Exe

Posted: Mon Jul 07, 2008 04: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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Call a Dll from an Exe

Posted: Mon Jul 07, 2008 05: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
Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM

Re: Call a Dll from an Exe

Posted: Tue Mar 16, 2010 06: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)

Posts: 340
Joined: Thu Jan 25, 2007 03:53 PM

Re: Call a Dll from an Exe

Posted: Tue Mar 23, 2010 06:06 PM

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

Tks

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: Call a Dll from an Exe

Posted: Thu Mar 25, 2010 10:08 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: Call a Dll from an Exe

Posted: 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

Continue the discussion