Hi
I'm having trouble with user-defined functions contained in a DLL. The functions don't work in 64bit Excel when called directly from a worksheet although they work fine when the DLL is compiled as 32-bit and called from 32-bit Excel. In 64-bit Excel they return strange values and usually crash Excel. I created a test DLL with a few simple functions with different data types as parameters that simply return the parameter passed to them converted to a double. The same problem exists whether the passed parameter is a double-precision float, 4-byte long, or 8-byte longlong.
The functions do work in 64-bit Excel when called from an intermediate Visual Basic function using code similar to the following and calling longlong1 from a worksheet:
Private Declare PtrSafe Function LongLongtest Lib "64bitDLL" (ByVal result As LongLong) As Double
Function longlong1(result As LongLong) As Double
longlong1 = LongLongtest(result)
End Function
I don't know if the problem is with Excel or the DLL. However, the DLL functions work fine when called from a console test program as well as from the Visual Basic interface in Excel. I've compiled the DLL in both C and C++ versions with Visual Studio Community, Embarcadero C++Builder XE8, and MinGW compilers and have the same problems with all of them. Does anyone have a suggestion re how to make the functions work when called directly from a worksheet?
Kaintuck1936