Safearray and IDL?? 
Author Message
 Safearray and IDL??

Hi Folks,

    I want pass back an Array on strings, so I thought I would use SAFEARRAY
*pMyArray, but the MIDL complains that SAFEARRAY* is a PVOID and it doesn't
like VOIDS, PVOIDS etc.

    Any idea what to do??

Cheers

Martin



Thu, 23 Sep 2004 23:21:55 GMT  
 Safearray and IDL??
Embed the SAFEARRAY in a LPVARIANT. i.e. something like this:

STDMETHODIMP CMyClass::MyMethod(/*[out, retval]*/ LPVARIANT pMyArray)
{
    if (pMyArray)
    {
        VariantInit(*pMyArray);
        pMyArray->vt = VT_BSTR | VT_ARRAY;
        pMyArray->parray = SafeArrayCreateVector(VT_BSTR, 0, nStrings);
        // fill the array
        return S_OK;
    }
    return E_INVALIDARG;

Quote:
}



Quote:
> Hi Folks,

>     I want pass back an Array on strings, so I thought I would use
SAFEARRAY
> *pMyArray, but the MIDL complains that SAFEARRAY* is a PVOID and it
doesn't
> like VOIDS, PVOIDS etc.

>     Any idea what to do??

> Cheers

> Martin



Fri, 24 Sep 2004 04:11:58 GMT  
 Safearray and IDL??
I think he means something different.

try the following in IDL:

     typedef SAFEARRAY(LONG)    MyData ; // Use your datatype instead of
LONG

  [id(1), helpstring("MyFunc")] HRESULT MyFunc([out]MyArray* MyData);

Edwin

Quote:
> Embed the SAFEARRAY in a LPVARIANT. i.e. something like this:

> STDMETHODIMP CMyClass::MyMethod(/*[out, retval]*/ LPVARIANT pMyArray)
> {
>     if (pMyArray)
>     {
>         VariantInit(*pMyArray);
>         pMyArray->vt = VT_BSTR | VT_ARRAY;
>         pMyArray->parray = SafeArrayCreateVector(VT_BSTR, 0, nStrings);
>         // fill the array
>         return S_OK;
>     }
>     return E_INVALIDARG;
> }



> > Hi Folks,

> >     I want pass back an Array on strings, so I thought I would use
> SAFEARRAY
> > *pMyArray, but the MIDL complains that SAFEARRAY* is a PVOID and it
> doesn't
> > like VOIDS, PVOIDS etc.

> >     Any idea what to do??

> > Cheers

> > Martin



Fri, 24 Sep 2004 15:04:57 GMT  
 Safearray and IDL??
Thanks both for some really usefull suggestions!!
Martin


Quote:
> I think he means something different.

> try the following in IDL:

>      typedef SAFEARRAY(LONG)    MyData ; // Use your datatype instead of
> LONG

>   [id(1), helpstring("MyFunc")] HRESULT MyFunc([out]MyArray* MyData);

> Edwin


> > Embed the SAFEARRAY in a LPVARIANT. i.e. something like this:

> > STDMETHODIMP CMyClass::MyMethod(/*[out, retval]*/ LPVARIANT pMyArray)
> > {
> >     if (pMyArray)
> >     {
> >         VariantInit(*pMyArray);
> >         pMyArray->vt = VT_BSTR | VT_ARRAY;
> >         pMyArray->parray = SafeArrayCreateVector(VT_BSTR, 0, nStrings);
> >         // fill the array
> >         return S_OK;
> >     }
> >     return E_INVALIDARG;
> > }



> > > Hi Folks,

> > >     I want pass back an Array on strings, so I thought I would use
> > SAFEARRAY
> > > *pMyArray, but the MIDL complains that SAFEARRAY* is a PVOID and it
> > doesn't
> > > like VOIDS, PVOIDS etc.

> > >     Any idea what to do??

> > > Cheers

> > > Martin



Sat, 25 Sep 2004 04:02:15 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. SAFEARRAY and IDL defined structure to VB

2. IDL for passing SAFEARRAY (BSTR)

3. IDL for passing SAFEARRAY(BSTR)

4. , IDL types, and SAFEARRAY

5. VC6 / VC7 : objidl.idl, oleaut32.lib & SAFEARRAYs

6. Copy 1D safeArray to 2D safearray

7. importing mshtml.idl in IDL file

8. IDL question - import "msxml2.idl";

9. How to create safearray or safearray?

10. Including an IDL file in an IDL file

11. Accessing Safearray of Safearrays in C++

12. Where to get "xmldom.idl" included in "MsXml.idl"???

 

 
Powered by phpBB® Forum Software