ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Bad DLL Calling Convention (Error 49) (https://www.excelbanter.com/excel-programming/281754-bad-dll-calling-convention-error-49-a.html)

Shaikh

Bad DLL Calling Convention (Error 49)
 
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.




Chip Pearson

Bad DLL Calling Convention (Error 49)
 
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.






Michael D. Ober[_2_]

Bad DLL Calling Convention (Error 49)
 
I am now getting the same error on code that used to work without changing
the machine. Here's my code.

dim r as range
Set r = CreateCollectorSummary(frmCreateDesk.CreateDeskShe et(CStr(c(i))))

Elsewhere in the same module I have:

Public Function CreateCollectorSummary(collSheet As Worksheet) As Range
....
Set CreateCollectorSummary = collSheet.Range(Cells(collStartRow, 1),
Cells(collSheetRow, columns(6)))
End Function

Note that my error occurs when CreateCollectorSummary actually returns. I
have single stepped through the CreateCollectorSummary function and the last
line in it (set createcolletorsummary = ...) does work and
CreateCollectorSummary is indeed a range.

Mike.


"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.








Shaikh

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.





All times are GMT +1. The time now is 12:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com