[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

Getting byte array from C# to ATL COM DLL

shiva

9/18/2007 3:32:00 PM

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.

--
Software Engineer
1 Answer

G Himangi

9/19/2007 4:08:00 AM

0

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....
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
---------


"shiva" <shiva@discussions.microsoft.com> wrote in message
news:F8637968-9311-4F33-ACEF-0FA12DFDE8C2@microsoft.com...
> 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.
>
> --
> Software Engineer