On 21 May 2007 15:22:15 -0700, diAb0Lo <ga********@gmail.comwrote:
>Arrays and structures in c++ are always By Reference Parameters (I
Think). However, I dont understand very well what you are trying to do.
OK, let me try and explain in a little more detail:
I'm trying (in VB2005) to interact with a third-party DLL written (I
think) in C++, but almost certainly not in a .Net version of the
language. Therefore I'm having to use COM Interop Services. I can call
several of the functions in the DLL successfully so I know that my
approach is working OK in general.
However there's one particular DLL function that is refusing to work
correctly. This is a function that requires a structure passed to it.
The structure definition (from the C/C++ documentation) is:
struct MyStructure
{
char parA;
char parB;
char parC;
}
where parA, B, C etc seem to take simple integer values like 0, 1, 2,
3 (even though they're typed as char).
I'm trying to simulate this structure in VB2005 as in:
Public Structure MyDotNetStructure
Dim parA as Byte
Dim parB as Byte
Dim parC as Byte
End Structure
and then setting the values for the structure elements like:
MyDotNetStructure.parA=Asc("0")
(Using the Asc() function to simulate the value that the C++ char
might have, was my thinking.)
then calling the DLL function by
Dim Response as short = DLLName.MyFunction(ByRef MyDotNetStructure)
(MyFunction is declared as a shared function in a class in my project
called DLLName that imports the InterOpServices.)
But I keep getting an 'invalid data' response from the function. I
presume that I haven't got the values or type of the structure right
but I'm not sure what to try next - there are quite a few permutations
of ByRef/ByVal, byte values etc etc. I was hoping someone might be a
bit more familiar with how to code this sort of communication.
Anyone please?