Getting byte array from C# to ATL COM DLL

G

Guest

Hi,

I have a VC++ COM DLL which is making calls to C#.net DLL. The C#.net DLL
functions which are byte array expecting SAFEARRAY from VC++ DLL. VC++ DLL
get called from my VB client where I need to pass this SAFEARRAY as VARIANT
to VB.
Could anyone help me how to get byte array from C# into VC++ and pass it in
VARIANT to my VB client application.

The current code I wrote seems not working can anyone help me in this -

SAFEARRAY *psa;
SAFEARRAYBOUND aDataItemBounds[1];
aDataItemBounds[0].lLbound = 0;
aDataItemBounds[0].cElements = nLength;

psa = SafeArrayCreate( VT_ARRAY, 1, aDataItemBounds );

// call to .net method
pInet->DotNetMethod(&psa, &lResult);

// copy into VARIANT to send to VB client
SafeArrayCopyData( psa, pVariant->parray);

Can anyone send me the code snippet for the above if it is wrongly coded.
 
G

G Himangi

I dont think .Net can understand SAFEARRAYS.
In any case, it would be better to pass a normal array to the .Net method,
then pin it and copy its contents to a SAFEARRAY.

---------
- G Himangi, Sky Software http://www.ssware.com
Shell MegaPack : GUI Controls For Drop-In Windows Explorer like Shell
Browsing Functionality For Your App (.Net & ActiveX Editions).
EZNamespaceExtensions.Net : Develop namespace extensions rapidly in .Net
EZShellExtensions.Net : Develop all shell extensions,explorer bars and BHOs
rapidly in .Net
 

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