Re: COM Interface intialization
So Igor what are you suggesting?
something like:
STDMETHODIMP CAnotherInterfaceImpl::GetItemInfo(IItemInfo** pRetUnk)
{
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.
//pInfo->AddRef(); //?? maybe ??
IItemInfo* piItemInfo = NULL;
hr = pInfo->QueryInterface(IID_IItemInfo, &piItemInfo);
/******** now do what with pInfo??? **************/
//pIinfo->Release(); //?? maybe ??
if(SUCCEEDED(hr) && piItemInfo)
{
*pRetUnk = pInfo;
return S_OK;
}
return hr;
}
Steven
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:Os570GOOHHA.4644@TK2MSFTNGP03.phx.gbl...
"Steven Edison" <EdisonCPP@newsgroups.nospam> wrote in message
news:%23vALX%23NOHHA.5064@TK2MSFTNGP04.phx.gbl
but I need SetSomeData() hidden from caller.
Note that the code calling SetSomeData has CItemInfo* pointer (to be
exact, a pointer to a class derived from CItemInfo), rather than
IItemInfo* pointer. Via this CItemInfo* pointer, the code has access to
any public methods of the class, whether or not they are exposed on a COM
interface.
The only way I can think of is another exposed interface with sets in
it? Is there a better way?
What's wrong with the way I've shown? You seem to misunderstand what's
going on there.
--
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