Re: a Query regarding COM Server and terminal services
in that case, if we want to fire a callback then all the clients will be
notified
is there any way by which we could differentiate between two clients in the
conncetion point callbacks in server?
am i missing something here?
here is the code that gets generated by wizard for connection point how will
i differentiate between the two clients here.
template<class T>
class CProxy_IAddEvents :
public IConnectionPointImpl<T, &__uuidof(_IAddEvents)>
{
public:
HRESULT Fire_ExecuteMe( LONG Result)
{
HRESULT hr = S_OK;
T * pThis = static_cast<T *>(this);
int cConnections = m_vec.GetSize();
for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();
_IAddEvents* p_IAddEvents =
reinterpret_cast<_IAddEvents*>(punkConnection.p);
if (p_IAddEvents != NULL)
hr = p_IAddEvents->ExecuteMe(Result);
/*IDispatch * pConnection = static_cast<IDispatch *>(punkConnection.p);
if (pConnection)
{
CComVariant avarParams[1];
avarParams[0] = Result;
avarParams[0].vt = VT_I4;
CComVariant varResult;
DISPPARAMS params = { avarParams, NULL, 1, 0 };
hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
}*/
}
return hr;
}
};
regards
--
d
"Brian Muth" wrote:
"d" <d@discussions.microsoft.com> wrote in message
news:612762C3-D067-4BDE-B8DD-260F77AD2B8D@microsoft.com...
hello Brian ,
thanks for your reply. earlier we were using connection points to perform
task.
Why not do it that way?
then later we decided that if we could pass a interface pointer to the COM
server from the client. we would be able to differentiate it.
i have one more concept problem. i have a class which interect with a
service.
now if any of the COM server client connections to the service classs with
IServicePtr ptr(__uuidof(Service))
i have a function in the "IService" interface called
GetInterface(ISomeInterface ** psf)
now in the COM EXE server
CService::GetInterface(ISomeInterface ** psf)
{
return CSomeInterface::CreateInstance(psf);
}
in this case if there are 10 users who create the Service COM object will
have
10 different -2 instance of "CSomeInterface::CreateInstance(psf);" i mean
10
ISomeInterface interface. am i wrong here??
No, you are correct. That is the standard paradigm.
i want to instentiate only ONE "CSomeInterface" Object to be returned
Then change the implementation of CService::GetInterface(ISomInterface
**psf). Perhaps it might look something like:
static ISomInterface *pSingleton = null;
CService::GetInterface(ISomeInterface (** psf)
{
if (pSingleton == null)
{
CSomeInterface::CreateInstance(pSingleton);
}
return pSingleton;
}
Howeever, I'd like to ask why? Why do you want the same COM object to be
handed out to all your clients? It can be done, but I suspect there is a
much better way to meet your requirements, which you haven't described.