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


.



Relevant Pages

  • Re: [PATCH 1/7] async: Asynchronous function calls to speed up kernel boot
    ... called within the caller's context. ... Hence this interface cannot be used to call might-sleep functions from ... will need to pass in the memory for the administration. ... If the callback function can sleep then the caller must be able to ...
    (Linux-Kernel)
  • Re: aspnet_wp.exe and COM+
    ... For releasing the interface i am not sure what you mean by, ... Such components do run "in-process", that means they run in the security context of the caller, so here the caller is allowed to call LogonUser(which I suppose you do in your Impersonate method) and the CreateEventEmailFolder Method doesn't need distributed transaction services either. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [UPDATE PATCH] push rounding up of relative request to schedule_timeout()
    ... >>sleeps probably need to use a different interface. ... > Adding 1 is easy enough for the caller and even easier to explain in the ... > instructions (i.e. this call sleeps for X jiffies edges). ... Lots of drivers basically do something like ...
    (Linux-Kernel)
  • Invalid callback object instance
    ... For asynchronous operations I use ... a callback interface to notify the application of completions. ... I receive as the first parameter (caller) is not valid. ...
    (microsoft.public.dotnet.framework.interop)
  • Re: [Lit.] Buffer overruns
    ... interface to getsays that it is the caller's responsibility to supply ... receive an exception if the index is out of bounds. ... You raised a concern that the caller might be "aborted". ... I do not know why you call it irresponsible programming. ...
    (sci.crypt)