Board index » delphi » Can't create OWL Window inside C++ DLL called from Delphi

Can't create OWL Window inside C++ DLL called from Delphi

I have a need to create a hidden OWL window inside a Borland C++ DLL
that is being called from a Delphi application.  I can create the DLL
easily enough, and when tested with a C++ application, the expected
results are achieved.  But, when I make the same call with the same
DLL from a Delphi app, I get exceptions all over the place.

I have modelled my DLL on the C++ example DLLHELLO which is in the
BC45\EXAMPLES\OWL\OWLAPI\DLLHELLO directory.  Even this example fails
with a Delphi app calling it.  I have checked all the usual traps
(eg. DS!=SS, Compatible Exceptions, RTTI, etc.) but cannot explain
why/what happens.

If anyone has any experience with this sort of thing, or can offer
any suggestions please email me.

Paul Sorenson

 

Re:Can't create OWL Window inside C++ DLL called from Delphi


You've compiled them with PASCAL keyword for calling
conventions?

Re:Can't create OWL Window inside C++ DLL called from Delphi


You've compiled them with PASCAL keyword for calling
conventions?

Re:Can't create OWL Window inside C++ DLL called from Delphi


Paul,

Quote
>   pa...@classware.com.au (Paul Sorenson) writes:
>  I have a need to create a hidden OWL window inside a Borland C++ DLL
>  that is being called from a Delphi application.  I can create the DLL
>  easily enough, and when tested with a C++ application, the expected
>  results are achieved.  But, when I make the same call with the same
>  DLL from a Delphi app, I get exceptions all over the place.

>  I have modelled my DLL on the C++ example DLLHELLO which is in the
>  BC45\EXAMPLES\OWL\OWLAPI\DLLHELLO directory.  Even this example fails
>  with a Delphi app calling it.  I have checked all the usual traps
>  (eg. DS!=SS, Compatible Exceptions, RTTI, etc.) but cannot explain
>  why/what happens.

My first guess (not having seen your DLL function parameters) would put the parameters at fault.  
(that is, if the DLL functions are declared as Far Pascal).  If you're declaring any Var
parameters, don't.  The first mistake I made creating Dll's in Delphi was to pass a variable using
Var instead of passing a pointer to the variable (at Borland's 1-900 tech support's advice, I
might add).  Pass a pointer and avoid the var keyword unless your DLL is Delphi's and is being
shared by Delphi apps.

I hope this helps.

John

-----------------------------------------------------------------------------
John Reynolds                          Delphi Visual Components
Custom Windows Programming [tm]        Tiled Backgrounds
Delphi/VB/C++                          Device-Independence Control
(505) 836-1384/264-0708                jre...@rt66.com (CIS: 71154,537)

Screen Dream Demo at http://www.teleport.com/~grump/delfiles.htm

Re:Can't create OWL Window inside C++ DLL called from Delphi


Quote
jre...@rt66.com wrote:

: Paul,

: >   pa...@classware.com.au (Paul Sorenson) writes:
: >  I have a need to create a hidden OWL window inside a Borland C++ DLL
: >  that is being called from a Delphi application.  I can create the DLL
: >  easily enough, and when tested with a C++ application, the expected
: >  results are achieved.  But, when I make the same call with the same
: >  DLL from a Delphi app, I get exceptions all over the place.
: >  
: >  I have modelled my DLL on the C++ example DLLHELLO which is in the
: >  BC45\EXAMPLES\OWL\OWLAPI\DLLHELLO directory.  Even this example fails
: >  with a Delphi app calling it.  I have checked all the usual traps
: >  (eg. DS!=SS, Compatible Exceptions, RTTI, etc.) but cannot explain
: >  why/what happens.
: >  

: My first guess (not having seen your DLL function parameters) would put the parameters at fault.  

...

There is another possibility - I dont have my OWL books here to check this,
but it seems more likely to me that some initialization has been missed out.
I would guess that a complex framework like OWL needs to run in an environment
which must be initialized when the program is loaded. The Borland C++ run-time
system would take care of this but, if you use the dll from a non BC++ app,
it will not have been performed. I'm sure I have seen some notes in the BC++
documentation about initialization functions which need to be called from
LibInit or LibMain in order to set things up.

Regards,

Martin Bradford.

Re:Can't create OWL Window inside C++ DLL called from Delphi


In article <45t50t$...@relay2.uk.mdis.com>, m...@mx1.uk.mdis.com
says...
Quote

>jre...@rt66.com wrote:
>: Paul,

>: >   pa...@classware.com.au (Paul Sorenson) writes:
>: >  I have a need to create a hidden OWL window inside a
Borland C++ DLL
>: >  that is being called from a Delphi application.  I can
create the DLL
>: >  easily enough, and when tested with a C++ application,
the expected
>: >  results are achieved.  But, when I make the same call
with the same
>: >  DLL from a Delphi app, I get exceptions all over the
place.
>: >  
>: >  I have modelled my DLL on the C++ example DLLHELLO which
is in the
>: >  BC45\EXAMPLES\OWL\OWLAPI\DLLHELLO directory.  Even this
example fails
>: >  with a Delphi app calling it.  I have checked all the
usual traps
>: >  (eg. DS!=SS, Compatible Exceptions, RTTI, etc.) but
cannot explain
>: >  why/what happens.
>: >  

>: My first guess (not having seen your DLL function

parameters) would put the parameters at fault.  
Quote

>...

>There is another possibility - I dont have my OWL books here
to check this,
>but it seems more likely to me that some initialization has
been missed out.
>I would guess that a complex framework like OWL needs to run
in an environment
>which must be initialized when the program is loaded. The

Borland C++ run-time

Quote
>system would take care of this but, if you use the dll from a
non BC++ app,
>it will not have been performed. I'm sure I have seen some
notes in the BC++
>documentation about initialization functions which need to be
called from
>LibInit or LibMain in order to set things up.

>Regards,

>Martin Bradford.

That looks likely.  When we get to the TWindow.Create call (eg
see DLLHELLO.CPP example) it bombed.  If can dig up the notes
you refer to, I would greatly appreciate you pointing me at
them.

Cheers,

Paul Sorenson

Other Threads