🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #310

GetOLEObject from ProcessID

#310
From: 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
Technical Details
Message-ID: <4847eb3d@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,13b28e23e37d0fbc,start
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 05 Jun 2008 15:33:48 +0200
From: Christian Lotze <Chrissi099@hotmail.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.14) Gecko/20080421 Thunderbird/2.0.0.14 Mnenhy/0.7.5.0
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: GetOLEObject from ProcessID
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 217.86.155.108
Message-ID: <4847eb3d@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1212672829 217.86.155.108 (5 Jun 2008 06:33:49 -0700)
Lines: 40
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail