COM Interface intialization
This is probably a very simple question.
And I feel like I should know this... but....
(And I hope this is okay under ATL group.)
If I have an interface implementation like this:
CItemInfo: public CComCoClass<CItemInfo, &CLSID_ItemInfo>
{
....
STDMETHOD(get_SomeData)(LONG* pVal); //prop
void SetSomeData(LONG nVal); //unexposed function
//other methods and props....
....
};
All the interface properties are read (get) only.
What I'd like to do is something like this:
STDMETHODIMP CAnotherInterfaceImpl::GetItemInfo(IUnknwn** pUnk)
{
CItemInfo* pInfo = new CItemInfo; //above impl class
pInfo->SetSomeData(0x42); //exposed through impl. class, but not the
interface
//so caller can't set
"somedata", but it can be done here.
//delete? AddRefs??
//just leave for caller's Release()??
*pUnk = (IUnknown*)pInfo;
return S_OK;
}
//final use:
CComPtr<IItemInfo> pInfo = NULL;
hr = pAnotherI->GetItemInfo((IUnknown**)&pInfo);
pInfo->get_SomeData(&someLong); //and other methods using the intialized
interface
In short I'd like to create and intialize private information within the
other interface and
give it to the caller. Is this even on the right track?
Thanks,
Steven