Call a Dll from an Exe

Post Reply
User avatar
don lowenstein
Posts: 201
Joined: Mon Oct 17, 2005 9:09 pm
Been thanked: 3 times
Contact:

Call a Dll from an Exe

Post by don lowenstein »

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
Antonio Linares
Site Admin
Posts: 42521
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

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
don lowenstein
Posts: 201
Joined: Mon Oct 17, 2005 9:09 pm
Been thanked: 3 times
Contact:

Post by don lowenstein »

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
Antonio Linares
Site Admin
Posts: 42521
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

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
don lowenstein
Posts: 201
Joined: Mon Oct 17, 2005 9:09 pm
Been thanked: 3 times
Contact:

Post by don lowenstein »

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
Antonio Linares
Site Admin
Posts: 42521
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Don,

I used the same sources as you: the ones from fwh\samples without modifying them:

Code: Select all | Expand

#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
don lowenstein
Posts: 201
Joined: Mon Oct 17, 2005 9:09 pm
Been thanked: 3 times
Contact:

Post by don lowenstein »

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
Antonio Linares
Site Admin
Posts: 42521
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

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
Romeo
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Re: Call a Dll from an Exe

Post by Romeo »

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

Post by Romeo »

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

Tks
User avatar
Antonio Linares
Site Admin
Posts: 42521
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Re: Call a Dll from an Exe

Post by Antonio Linares »

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 42521
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Re: Call a Dll from an Exe

Post by Antonio Linares »

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
Post Reply