Accessing a ATL COM function with BYTE * from a C# application

  • Thread starter Thread starter Jana1978
  • Start date Start date
J

Jana1978

Guest
Hi,


I am accessing a third party ATL COM function with argument BYTE * from a C# application. When I call the function from a C++ application, it is working as expected. For calling from the C# application, I used MIDL to create the type library and used tlbimp to create a interop DLL which is used by the C# application. Since the C++ code had BYTE * as argument, MIDL was converting it into C# byte during TLB generation. Due to this, the C# application is not working as expected. I tried manually modifying the header file to use SAFEARRAY(BYTE) instead but that too doesn't provide the expected results. Since I don't have access to the code for COM server, what is the alternative way I can overcome this issue?

For e.g. if the function is like BOOL TestFunc(in BYTE *pBuffer, int nBufLength);

it is converted to bool TestFunc(ref byte pBuffer, int nBufLength) in C#.

If I use SAFEARRAY in the header file, it is converted into

bool TestFunc(byte [] pBuffer, int nBufLength) in C# but doesn't work as expected.


Regards,

Janardhanan.R.



Janardhanan.R.

Continue reading...
 
Back
Top