How to convert a SafeArray of bytes into a structure 
Author Message
 How to convert a SafeArray of bytes into a structure

I've got a COM object with a method that returns a WIN32_FIND_DATA
structure in the form of a SAFEARRAY.

From normal (unmanaged) C++ I can access the data like this:

_variant_t v = m_pComObj->GetOriginalFileDetails( pFileName );

if ( v.vt == ( VT_ARRAY | VT_UI1 ) )
{
  SAFEARRAY* psa = v.parray;
  /* Check it's what I think it is */
  if ( psa->rgsabound[0].cElements == sizeof( WIN32_FIND_DATA ) )
  {
    WIN32_FIND_DATA * pfd;
    if ( S_OK == SafeArrayAccessData( psa, (void **) &pfd ) )
    {

In C# I've currently got this:

    object w32data = ComObj.GetOriginalFileDetails( fname );

and when I examine the w32data object in the de{*filter*} it appears as an
array of bytes - which I can see are the contents of the
WIN32_FIND_DATA structure.

Short of a horrible brute force method, is there a way I can access
this data as a WIN32_FIND_DATA structure from C# ?

Dave Lowndes
--
MVP VC++ FAQ: http://www.*-*-*.com/
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Sat, 02 Aug 2003 18:19:35 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Converting byte[] to structure without Marshal?

2. Convert Byte to HexString to Byte.

3. converting an array of bytes ( BYTE* ) to a BITMAP struct

4. Fire SAFEARRAY(BYTE) to outer COM object crashes

5. BYTE buffer to SAFEARRAY

6. Byte stream got messed up in BSTR, CANNOT use SafeArray

7. Byte stream got messed up in BSTR, CANNOT use SafeArray

8. Help: Passing structure including SafeArrays to C++ DLL

9. SAFEARRAY and IDL defined structure to VB

10. safearray of structures

11. SafeArray of structures

12. how to convert a SAFEARRAY to VARIANT?

 

 
Powered by phpBB® Forum Software