HighTechTalks DotNet Forums  

Getting byte array from C# to ATL COM DLL

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Getting byte array from C# to ATL COM DLL in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
shiva
 
Posts: n/a

Default Getting byte array from C# to ATL COM DLL - 09-18-2007 , 11:32 AM






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

Reply With Quote
  #2  
Old   
G Himangi
 
Posts: n/a

Default Re: Getting byte array from C# to ATL COM DLL - 09-19-2007 , 12:07 AM






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


"shiva" <shiva (AT) discussions (DOT) microsoft.com> wrote

Quote:
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



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.