Board index » delphi » Delphi created DLL calling from MS Excel (HELP!!)

Delphi created DLL calling from MS Excel (HELP!!)

I have written a DLL in Delphi and I am calling the Delphi function from
within an Excel Macro i.e. =Call(dllname, function name, args,etc..).

Here is the problem:
When I run this as a EXE it works fine.  When I convert it to a DLL I get
an error on a StrToFloat function call.  If I comment out that call, the
DLL works fine.

By the way, I make calls to the StrToInt function also.  It still works.
 What's the deal with StrToFloat and Excel, or am I barking up the wrong
tree.

Thanks in advance,
Phil Curtis

 

Re:Delphi created DLL calling from MS Excel (HELP!!)


Quote
pcur...@ionet.net (Phil Curtis) wrote:
>I have written a DLL in Delphi and I am calling the Delphi function from
>within an Excel Macro i.e. =Call(dllname, function name, args,etc..).

>Here is the problem:
>When I run this as a EXE it works fine.  When I convert it to a DLL I get
>an error on a StrToFloat function call.  If I comment out that call, the
>DLL works fine.

>By the way, I make calls to the StrToInt function also.  It still works.
> What's the deal with StrToFloat and Excel, or am I barking up the wrong
>tree.

>Thanks in advance,
>Phil Curtis

I have had a hunt through the  excel developers kit, and found a
comment, that has worried me about writing xll's, and the IEEE 8 -byte
floating point format (double).  The following is an extract from the
devlopers kit.

E Data Type

Microsoft Excel expects a DLL using the E data type to pass pointers
to floating point numbers on the stack.  This can cause problems with
some languages (for example Borland C++) that expect the number to be
passed on the coprocessor emulator stack.  The workaround is to pass a
pointer to the number on the coprocessor stack.  The following example
shows how to return a double from Borland C++:

typedef double FAR * lpDbl;
extern "C" lpDbl FAR PASCAL _export AddDbl (double D1, double D2, WORD
npDbl)
{

I have n't even installed my copy of delphi so I do not know if this
is your problem. I got delphi because I believe that pascal is much
easier than C for writing DLL'S.

Regarding Excell, if you have version 5.0 you must have version 5.0c
if you want to do anything interesting in the 16 bit version, as the
earlier versions are full of bugs.  The 32 bit version and mac
versions are fine.

Regards

ron...@calleva.com

Other Threads