473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

UCOMIRunningObjectTable.GetObject Method

Wes
Can anyone tell me how to change this C# code to grab all instances of an
application that is running? Right now, it only will output to the first
opened single document interface application n times (n being the number of
the same SDI app running). My end goal is to be able to pass in a windows
handle and be able to get the appropriate application instance. I know this
might be a C# newsgroup question, but almost all of this code has been taken
from this newsgroup. If I get it to work, I will post source to here so
that all may use. This might be a stupid question, so if someone has a good
tutorial link they think might help me, I would be very grateful for this as
well. Thanks to anyone who takes a look!

Wes

using System;
using System.Runtime.InteropServices;
using SomeSDICom;

namespace Hei.Utility.COMConnectors {

public class ROTWalker {
[DllImport ("Ole32.Dll")]
public static extern int CreateBindCtx ( int reserved, out UCOMIBindCtx
bindCtx );

public ROTWalker() {
UCOMIBindCtx bc;
ROTWalker.CreateBindCtx ( 0, out bc );
UCOMIRunningObjectTable rot;
bc.GetRunningObjectTable ( out rot );

UCOMIEnumMoniker enumMkr;
rot.EnumRunning ( out enumMkr );
UCOMIMoniker[] elts = new UCOMIMoniker[1];
int cnt;
int ret;
Object o = new object();
SomeSDIComApplication app;
string displayName;
while ( ( ret = enumMkr.Next ( 1, elts, out cnt ) ) >= 0 && ( cnt >
0 ) ) {
elts[0].GetDisplayName ( bc, null, out displayName );
Console.WriteLine(displayName);
//I'm not sure what this next line of code does, but I couldn't get it to
work
// elts[0].BindToObject(bc, null, ref null, out o);

//why does this next line always connect to the same instance, even though
there are
//different monikers?
rot.GetObject(elts[0], out o);
if (displayName == "!{1365A45F-0C8F-4806-A26A-6B22AD37EC66}") {
app = ((SomeSDIComApplication) o);

//this is the line that prints out to the first instance.
//I have been trying to get it to work with AutoCAD
//but I would like to write something generic enough to work with Word or
excel as well
app.OutputSomething("Output to this running instance.\n\n");
}//if
}//while
}//constructor
}//class
}//ns


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 17 '05 #1
0 1677

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Rich | last post by:
Hello, I have not been working with ASP for too long at this time and am not real familiar with a lot of things about ASP. I have searched for articles on the following question but not come up...
2
by: CJM | last post by:
I'm building an ASP app that uses Windows Authentication (IWA). I have an authentication routine that assesses if & how the user can use the application (see code snippet below). Users of a...
5
by: Andrei | last post by:
Hello, I posted yesterday the same problem, but now I want to be more specific about it. My intention is to create a windows service to process some Word documents. If I use CreateObject to...
0
by: AP | last post by:
Hello, I am trying to create an object and then use the getObject() method to set my VB object to a running instance of the object within a window in a windows program that is currently running....
3
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet...
1
by: Martyn Gwynne | last post by:
I am progressing with GetObject .. The following code will open and print a report. I enquired how to open, maximise WITHOUT printing by default and it was suggested that I look at further...
5
by: Yong Yu | last post by:
Dear All, I have to move my VB code to C#. But I have no idea on the GetObject method in Vb. ----------------------------------------- Set dom = GetObject("WinNT://" & domain)...
3
by: perspolis | last post by:
Is there a method like GetObject in vb to get an instance of current object runnig??
5
by: newscorrespondent | last post by:
This method does not fail if the site is not running! Is there a way to check the proxy for failure? Thanks Tom
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.