
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.