Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 18th, 2003, 11:47 AM
Registered User
 
Join Date: Aug 2003
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default UCOMIRunningObjectTable.GetObject

I have been trying to write a utility which will walk through the running objects table and return the object based on the class name and window handle. I have most of the code so far, but now I am stuck. Whenever I walk through the ROT, my code only grabs the first instance opened of the application. It does output x times where x is the number of acad apps opened. I wish for it to iterate through each instance of AutoCAD and output something to each one. Any MS gurus out there that can tell me how to do this? I am pretty new to ROT and monikers, so if you can just point me to the right objects/methods, I would be forever grateful!

Thanks,
Wes

Code:
using System;
using System.Runtime.InteropServices;
using AutoCAD;

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();
            AcadApplication acadApp;
            while ( ( ret = enumMkr.Next ( 1, elts, out cnt ) ) >= 0 && ( cnt > 0 ) ) {
                string displayName;
                elts[0].GetDisplayName ( bc, null, out displayName );
                Console.WriteLine(displayName);
                rot.GetObject(elts[0], out o);
                if (displayName == "!{1365A45F-0C8F-4806-A26A-6B22AD37EC66}") {
                    acadApp = ((AcadApplication) o);
                    acadApp.ActiveDocument.Utility.Prompt("hehehehe\n\n");
                }
            }
        }
    }
}

Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GetObject jdhock8865 Visual Basic 2005 Basics 2 November 3rd, 2008 09:29 PM
getobject() failure- recent Loralee Access 2 November 24th, 2006 02:29 PM
getObject() and shell() question using automation juneBugz Access VBA 0 August 29th, 2005 08:46 PM
GetObject Trap bostek VBScript 2 November 24th, 2004 02:39 AM
why GetObject with IIS is not working alyeng2000 ASP.NET 1.x and 2.0 Application Design 0 September 15th, 2004 09:00 AM



All times are GMT -4. The time now is 04:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.