Re:Delphi DLLs and excel
: Anders Pelli <pe...@shh.fi> wrote:
Quote
>I had problems getting a DLL function to
>return real values when called from excel.
>Another function with integer parameters and integer
>return value worked just fine. Any good references
>on writing DLLs for Excel?
You must be using 16bit. As far as I can tell this behaviour does not
occur in 32bit.
I would be VERY grateful if you could share your experience in writing
DLLs for Excel. I am about to do the same.
References:
a) The Excel SDK
b) Check Lloyd's help file (available from Borland -> Delphi download
section, near the bottom) why returning a floating point value via a
function to EVERY 16bit Microsoft product (Excel, VC etc.) is a
problem - and learn how it can be fixed. To give you a taste:
{ cut from code, stripped down, not guaranteed to work }
function E(x: double;NearPtr: word): Pointer;
var
TempPointer: ^double; { make this {*word*99}py behaviour explicit }
begin
try
Result := Ptr(SSeg, NearPtr);
TempPointer := Ptr(SSeg, NearPtr);
TempPointer^ := 1.225346
except
Error;
end;
end;
c) Quick workaround: do not return a float, but a use a var parameter
to return it:
procedure(x,y,z: double; var something: double)
--
Stefan.Hoffmeis...@UNI-Passau.DE
http://kakadu.rz.uni-passau.de/~w4hoff01/
University of Passau, Bavaria, Germany