Thank you very much.
Hi,
We have been using this code to get the interface pointer to the
running application. Check out if it helps.
GetInterfacePtr(_bstr_t aProviderName, IUnknown** pUnknown )
{
IRunningObjectTable* spTable;
HRESULT hr = GetRunningObjectTable( 0, &spTable ); /* Get the
ROT interface pointer */
if ( SUCCEEDED( hr ) )
{
IEnumMonikerPtr pEnumAllMonikersInRot;
hr = spTable->EnumRunning(&pEnumAllMonikersInRot);
if ( SUCCEEDED(hr) )
{
_bstr_t bstrtCurName;
IMonikerPtr spMoniker = NULL;
while ( SUCCEEDED(pEnumAllMonikersInRot-
Next(1, &spMoniker, NULL)) && (NULL != spMoniker) ) {
/* Loop thru all the interfaces in the
enumerator looking for our reqd interface */
IBindCtxPtr spContext = NULL;
hr = CreateBindCtx( 0, &spContext ); /*
Create a bind context */
if ( SUCCEEDED(hr) ) {
WCHAR* wsCurName = NULL;
hr = spMoniker-
GetDisplayName( spContext,NULL, &wsCurName ); /* Get the display name
*/
bstrtCurName = wsCurName;
if ( SUCCEEDED(hr) &&
aProviderName == bstrtCurName ) { /* We have got our required
interface pointer */
hr = spTable-
GetObject( spMoniker, pUnknown );
break;
}
}
spMoniker.Release();
}
}
}
}
Best Regards,
Senthil