Z
zorrothefox.groups
Hi,
I'm currently involved in porting a ATL COM dll project to
C#. For compatibility reasons, the signatures of the functions in the
exported .TLB file should remain the same when ported to C#. For the
majority, this seems to be a smooth process.
However, two functions in the Old COM project seem to be giving me a
hard time during porting. One function WriteBytes() basically takes in
a BYTE array, and transfers the values in the array to the Serial
Port. Similarly, ReadBytes() takes a BYTE array as a parameter, and
copies the values read in from the Serial Port into the array.
The function signatures for the ATL COM project are as below...
HRESULT ReadBytes([in]VARIANT *varBuffer, [in]long lNoOfBytes,
[out,retval]long* lBytesRead);
HRESULT WriteBytes([in]VARIANT *varBuffer, [in]long lNoOfBytes,
[out,retval]long* lBytesWritten);
Internally, what the old project does is..
BYTE buffer[512];
long retval=0;
_variant_t *varBuffer = new _variant_t;
varBuffer->byref = buffer;
pSerialInterface->ReadBytes(varBuffer,512,&retval);
Since C# does not support the VARIANT datatype, I declared the
functions in C# as members of an interface that I implement, as below.
Int32 ReadBytes(ref Object pOb, Int32 lNoOfBytes);
Int32 WriteBytes(ref Object pOb, Int32 lNoOfBytes);
My problem is, how do I convert the Object reference properly, so that
I get the base addresses of the arrays being passed in as VARIANT *.
Please help me out here...
Thanks in advance,
Bharat.
I'm currently involved in porting a ATL COM dll project to
C#. For compatibility reasons, the signatures of the functions in the
exported .TLB file should remain the same when ported to C#. For the
majority, this seems to be a smooth process.
However, two functions in the Old COM project seem to be giving me a
hard time during porting. One function WriteBytes() basically takes in
a BYTE array, and transfers the values in the array to the Serial
Port. Similarly, ReadBytes() takes a BYTE array as a parameter, and
copies the values read in from the Serial Port into the array.
The function signatures for the ATL COM project are as below...
HRESULT ReadBytes([in]VARIANT *varBuffer, [in]long lNoOfBytes,
[out,retval]long* lBytesRead);
HRESULT WriteBytes([in]VARIANT *varBuffer, [in]long lNoOfBytes,
[out,retval]long* lBytesWritten);
Internally, what the old project does is..
BYTE buffer[512];
long retval=0;
_variant_t *varBuffer = new _variant_t;
varBuffer->byref = buffer;
pSerialInterface->ReadBytes(varBuffer,512,&retval);
Since C# does not support the VARIANT datatype, I declared the
functions in C# as members of an interface that I implement, as below.
Int32 ReadBytes(ref Object pOb, Int32 lNoOfBytes);
Int32 WriteBytes(ref Object pOb, Int32 lNoOfBytes);
My problem is, how do I convert the Object reference properly, so that
I get the base addresses of the arrays being passed in as VARIANT *.
Please help me out here...
Thanks in advance,
Bharat.