Click here to Skip to main content

Mem 9021960 asked:

Open original thread
Dear Friends!
I have problem while working with ATL(VS2008, C++).
I must use SAFEARRAY(IMyObject*)* parameters in idl file.
If SAFEARRAY(double)*, then use the CComSafeArray..., but for interfaces or my structures, I don't know how to solve.
Thank you in advanced.
 
The idl file is...
 
...
 
interface IMyObj2;
...
 
typedef struct SMyObj2{
    IMyObj2 * iobject;
}SMyObj2;
 
...
 
//.IMyObj2
[
	object,
	uuid(3454B81A-65A9-4F3E-8678-1D5F82B25837),
	oleautomation,
	nonextensible,
	helpstring("IMyObj2 Interface"),
	pointer_default(unique)
]
interface IMyObj2 : IUnknown{
	[propget, helpstring("property ID")] 
	HRESULT ID([out, retval] LONG* pVal);
	[propput, helpstring("property ID")] 
	HRESULT ID([in] LONG newVal);
};
 
...
 

[
	object,
	uuid(EF532C8B-12A9-4FEC-B91C-D7502FD68874),
	oleautomation,
	nonextensible,
	helpstring("IArrayMan3 Interface"),
	pointer_default(unique)
]
 
interface IArrayMan3 : IUnknown{
	[helpstring("method GetArray")] 
	HRESULT _stdcall GetArray2(SAFEARRAY(SMyObj2)* pArray);
	[helpstring("method PutArray")] 
	HRESULT _stdcall PutArray2(SAFEARRAY(SMyObj2) pArray);
};
 
C++ file...
STDMETHOD(GetArray2)(SAFEARRAY** pArray)
{
	CComSafeArray<IUnknown*> ppp;//.Compile Okay.
//	CComSafeArray<SMyObj2, VT_VARIANT> arr;//.Compile Error
//      CComSafeArray<IMyObj2*> ttt;//.Compile Error
	return S_OK;
}
Tags: C++, ATL

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100