View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Shaikh Shaikh is offline
external usenet poster
 
Posts: 2
Default Bad DLL Calling Convention (Error 49)

Dear Chip,

Here is my VBA declaration:

Declare Function steam67 Lib "steam67.dll" (ByRef temperature As
Double, ByRef pressure As Double, ByRef quality As Double, ByRef
weight As Double, ByRef enthalpy As Double, ByRef entropy As Double,
ByRef saturation_temperature As Double, ByRef saturation_pressure As
Double, ByRef degrees_superheat As Double, ByRef degrees_subcooling As
Double, ByRef viscosity As Double, ByRef critical_velocity As Double,
ByVal action As Integer) As Integer

I have put steam67.dll in C:\Windows\System32 folder

Then I am calling this dll in following function:

Public Function flash67(temperature As Double, _
pressure As Double, _
quality As Double, _
enthalpy As Double, _
entropy As Double) As Variant
Dim weight As Double
Dim saturation_temperature As Double
Dim saturation_pressure As Double
Dim degrees_superheat As Double
Dim degrees_subcooling As Double
Dim viscosity As Double
Dim critical_velocity As Double
Dim action As Integer
Dim iret As Integer

action = 2 'viscosity=1, crit_vel=2

iret = steam67(temperature, pressure, quality, weight, enthalpy,
entropy, saturation_temperature, saturation_pressure,
degrees_superheat, degrees_subcooling, viscosity, critical_velocity,
action)

flash67 = Array(temperature, pressure, quality, weight, enthalpy,
entropy, saturation_temperature, saturation_pressure,
degrees_superheat, degrees_subcooling, viscosity, critical_velocity)

End Function

I am getting error at iret = steam67(temperature, pressure ....) line
of the code. I don't know what but I think there is a problem of using
this line in office 2003. Office XP (2002) uses the same structure of
the program and does not give any error.


In steam67.h file I checked the data type and they are as following:

int steam67(double *temperature, double *pressure, double *quality,
double *weight, double *enthalpy, double *entropy, double
*saturation_temperature, double *saturation_pressure, double
*degrees_superheat, double *degrees_subcooling, double *viscosity,
double *critical_velocity, int action);

I will greatly appreciate your help. Thanks


"Chip Pearson" wrote in message ...
Shaikh,

Typically, you get a Bad Calling Convention error when arguments passed to
the DLL do not match the data type (long, integer, etc) or the reference
type (byval or byref) specified by the DLL.

Post your Declare statement and the code you are using to call the function.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Shaikh" wrote in message
...
Hello,
I have the following strange problem.
I have an excel program that uses a dll. Every thing is working fine

(still now) with my old laptop. But giving me error 49 - Bad DLL Calling
Convention (Error 49) - in my new laptop. Files and dll are same in both the
machine.

Both laptops have windows XP
Old laptop has Office XP (Office 2002) and new laptop has Office 2003

I am suspecting something wrong in Office 2003. Can anybody please tell me

whats the problem?

-Thanks.