🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
1 messages
1 total messages Started by Christian Lotze Thu, 05 Jun 2008 13:33
GetOLEObject from ProcessID
#310
Author: Christian Lotze
Date: Thu, 05 Jun 2008 13:33
40 lines
2025 bytes
Hi All,
another Problem:

During a special drag'n'drop operation i have to detect an 
excel.application object, even if there are multiple instances running. 
I've got ProcessId of selected Excel instance. How to get OLEObject from 
this ProcessId?

I'm looking in RunningObjectTable, but didn't find OLE-Object in IMoniker.

IRunningObjectTable*	rot;
HRESULT hr = ::GetRunningObjectTable(0, &rot);
IMoniker* moniker = NULL;
IEnumMoniker* enumMoniker;

CLSID clsid;
IBindCtx* binder;
IUnknown * Application;
Variant Excel;

     hr = ::CreateBindCtx(0, &binder);
     BSTR displayName;

     hr = rot->EnumRunning( &enumMoniker );
     hr = enumMoniker->Next( 1, &moniker, NULL );
     while( hr == S_OK )
     {
       moniker->GetClassID( &clsid );
// check for excel here!!!
       moniker->GetDisplayName( binder, NULL, &displayName );

// do that only if it's EXCEL!!!
       rot->GetObject(moniker, &Application );
       Excel = (Variant)Application;

       hr = enumMoniker->Next( 1, &moniker, NULL );
     }

Any hints? Thanks for Help,
Christian
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads