Problem with SAFEARRAY as property accessors.

A

Ahmad Jalil Qarshi

i want to store binary data into my property. i read earlier positing on
"microsoft.public.dotnet.languages.vc" group with subject as SAFEARRAY in
attributed ATL7 Project. i followed the same approach but unfortunately i
failed to do that.
i declared the property accessors as follow in my idl file.

[propget, id(2), helpstring("property Data")] HRESULT Data([out, retval,
satype(byte)] SAFEARRAY * *pVal);
[propput, id(2), helpstring("property Data")] HRESULT Data([in,
satype(byte)] SAFEARRAY * newVal);

when i compile code i get following error.
error MIDL2025 : syntax error : expecting ] or , near "satype".

any body there to help me.

Thanks in advance.

Ahmad Jalil Qarshi
 
I

Igor Tandetnik

Ahmad Jalil Qarshi said:
[propget, id(2), helpstring("property Data")] HRESULT Data([out,
retval, satype(byte)] SAFEARRAY * *pVal);
[propput, id(2), helpstring("property Data")] HRESULT Data([in,
satype(byte)] SAFEARRAY * newVal);

when i compile code i get following error.
error MIDL2025 : syntax error : expecting ] or , near "satype".

In IDL, the syntax is different:

[propget, id(2), helpstring("property Data")]
HRESULT Data([out, retval] SAFEARRAY(BYTE) *pVal);
[propput, id(2), helpstring("property Data")]
HRESULT Data([in] SAFEARRAY(BYTE) newVal);

The syntax in your post is used in a .cpp file when building an
attributed project.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 
A

Ahmad Jalil Qarshi

Thanks Igor!
i have done that according to your instruction. but still i get same error
twice which is here under.

error C2259: 'CComObject<class CTestLoadObj>' : cannot instantiate abstract
class due to following members:
c:\program files\microsoft visual
studio\vc98\atl\include\atlcom.h(1823) : while compiling class-template
member function 'long __stdcall ATL::CComCreator<class ATL::CComObject<class
CTestLoadObj> >::CreateInstance(void *,const struct _GUID
&,void ** )'

could you plz tell me how to define these properties in .cpp file also.
i suppose that it would be like that:
STDMETHODIMP CTestLoadObj::get_Data(SAFEARRAY *pVal)
{
}
STDMETHODIMP CTestLoadObj::put_Data(SAFEARRAY pVal)
{
}
but i m sure that i m wrong that's y i m getting errors. please guide me.
Thanks in advance.
Ahmad Jalil Qarshi


Igor Tandetnik said:
Ahmad Jalil Qarshi said:
[propget, id(2), helpstring("property Data")] HRESULT Data([out,
retval, satype(byte)] SAFEARRAY * *pVal);
[propput, id(2), helpstring("property Data")] HRESULT Data([in,
satype(byte)] SAFEARRAY * newVal);

when i compile code i get following error.
error MIDL2025 : syntax error : expecting ] or , near "satype".

In IDL, the syntax is different:

[propget, id(2), helpstring("property Data")]
HRESULT Data([out, retval] SAFEARRAY(BYTE) *pVal);
[propput, id(2), helpstring("property Data")]
HRESULT Data([in] SAFEARRAY(BYTE) newVal);

The syntax in your post is used in a .cpp file when building an
attributed project.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 
I

Igor Tandetnik

Ahmad Jalil Qarshi said:
error C2259: 'CComObject<class CTestLoadObj>' : cannot instantiate
abstract class due to following members:
c:\program files\microsoft visual
studio\vc98\atl\include\atlcom.h(1823) : while compiling
class-template member function 'long __stdcall ATL::CComCreator<class
ATL::CComObject<class CTestLoadObj> >::CreateInstance(void *,const
struct _GUID &,void ** )'

could you plz tell me how to define these properties in .cpp file
also.
i suppose that it would be like that:
STDMETHODIMP CTestLoadObj::get_Data(SAFEARRAY *pVal)
{
}
STDMETHODIMP CTestLoadObj::put_Data(SAFEARRAY pVal)
{
}

A SAFEARRAY(Whatever) parameter in IDL becomes SAFEARRAY* in C++.
SAFEARRAY(Whatever)* becomes SAFEARRAY**, and so on. In other words, in
C++ you always specify one extra level of indirection compared to IDL
syntax.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 
A

Ahmad Jalil Qarshi

Thanks again!
i have done that. its compiled now successfully. but my object is not
persisting this safearray, whereas other properties of this object persist.
Isn't it possible to persist SAFEARRAYs.
Thanks.
Ahmad Jalil Qarshi
 
I

Igor Tandetnik

Ahmad Jalil Qarshi said:
i have done that. its compiled now successfully. but my object is not
persisting this safearray, whereas other properties of this object
persist. Isn't it possible to persist SAFEARRAYs.

ATL persistence implementation (IPersistStreamInitImpl et al) indeed
does not support safearrays. You will have to write your own.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top