External dll

M

Marino

Hi!

I have a problem in calling a function from an external dll source.
Prototype for a function is given in vb code

Declare Function GetMessageData Lib "c:\windows\system\smartdll.dll" (ByVal
theLength As Integer, ByRef theMessageLength As Integer, ByVal
theMessageData As String) As Integer

I would like to call this funcition from c# and I just can't seem to get a
hang of it...
Manufacturer description is very scarce...
Where should I use the string, or do I need StringBuilder, can anyone help?

Thanks,
Marino
 
G

GArlington

Hi!

I have a problem in calling a function from an external dll source.
Prototype for a function is given in vb code

Declare Function GetMessageData Lib "c:\windows\system\smartdll.dll" (ByVal
theLength As Integer, ByRef theMessageLength As Integer, ByVal
theMessageData As String) As Integer
I suspect that your problem comes from "ByRef theMessageLength As
Integer",
you should call the finction with (theLength, ref theMessageLength,
theMessageData)
see REF before theMessageLength
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi!

I have a problem in calling a function from an external dll source.
Prototype for a function is given in vb code

Declare Function GetMessageData Lib "c:\windows\system\smartdll.dll" (ByVal
theLength As Integer, ByRef theMessageLength As Integer, ByVal
theMessageData As String) As Integer

I would like to call this funcition from c# and I just can't seem to get a
hang of it...
Manufacturer description is very scarce...
Where should I use the string, or do I need StringBuilder, can anyone help?

Thanks,
Marino

Does the function works in VB?
Is that VB.NET or VB6?

What kind of dll is it? Is it a win32 one or a COM dll?
 
M

Marino

Yes, that seems to be the problem. Thank you!
Even though that works in some functions, while other have problems.
I am currently thinking that the problem is within incompatibile types,
because I am programming in .net while this dll seems to function the best
in "old" languages...
Will keep trying...
 
B

Ben Voigt [C++ MVP]

Marino said:
Yes, that seems to be the problem. Thank you!
Even though that works in some functions, while other have problems.
I am currently thinking that the problem is within incompatibile
types, because I am programming in .net while this dll seems to
function the best in "old" languages...
Will keep trying...

VB6 Integer is .NET System.Int16, not the same as C# int (which is
System.Int32)

That may be your problem.
 
M

Marino

This solved the problem... Strange dll, it references as though params are
long, but in some params it only accepts int16, in some int and in some
long... Very strange..

Thank you a bunch for your help!!
 
B

Ben Voigt [C++ MVP]

Marino said:
This solved the problem... Strange dll, it references as though
params are long, but in some params it only accepts int16, in some
int and in some long... Very strange..

I highly doubt that any of the parameters are a C# long (System.Int64).
LONG in C++ and Long in VB6 are the same as .NET System.Int32.
 
M

Marino

Seems strange to me to, but if I use any other filetype other than long it
doesn''t work...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top