4 Replies Latest reply on Aug 8, 2014 11:46 AM by peter.kurlak

    Connect to second dxdesigner?




      Is there a way to check if an other Dxdesigner application is running and to connect to it?

      With expedition PCB this is possible with PcbApp.Utility.FindApplication(cnt) but I couldn't find anything like this for DxDesigner.

        • 1. Re: Connect to second dxdesigner?

          If you do set one to the get obect and open the second one yourself, it should work.

          app1 = getobject(...)

          app2 = createobject(...)



          • 2. Re: Connect to second dxdesigner?


            I Don't want to create a new object but is for a vbs script started in expedition PCB that needs to connect to the dxdesigner project of this board (which is already opened) but if you have 2 dxdesigner programs started it will connect to the first one which might be the incorrect project.


            I added a check to see if PCB Path on the active design matches the PCB path from Expedition PCB to stop the script but would be better if I can somehow connect to other instances of Dxdesigner to find the correct one.

            • 3. Re: Connect to second dxdesigner?



              I stumbled over the same issue and opened two SRs in 2010, 2332128450 for DxD and 2332128540 for EXP (stucked at getObject(), not aware of 'FindApplication').

              Both were closed without solution.

              Now I've learned at least how to do it for EXP, thanks.



              Best Regards


              • 4. Re: Connect to second dxdesigner?

                Since I develop in C#, I came up with the following solution:


                internal static class RunningObjectTable
                    // call into ole22.dll to retrieve the GetRunningObjectTable function
                    private static extern int GetRunningObjectTable(int reserved, 
                        out IRunningObjectTable prot);
                    // call into ole32.dll to retrieve the CreateBindCtx function
                    private static extern int CreateBindCtx(int reserved, 
                        out IBindCtx ppbc);
                    /// <summary>
                    /// Returns a list of instance objects from the running objects table (ROT)
                    /// that match the specified application name (<paramref name="appName"/>).
                    /// </summary>
                    /// <param name="appName">Name of the application to find instances for.</param>
                    /// <returns>A list of instances of the specified application.</returns>
                    public static IEnumerable<T> GetInstancesWithName<T>(string appName)
                        IRunningObjectTable runningObjTable;
                        IEnumMoniker monikerEnum;
                        IMoniker[] monikers = new IMoniker[1];
                        List<T> instances = new List<T>();
                        GetRunningObjectTable(0, out runningObjTable);
                        runningObjTable.EnumRunning(out monikerEnum);
                        // loop through the ROT looking for appName
                        while (monikerEnum.Next(1, monikers, IntPtr.Zero) == 0)
                            IBindCtx ctx;
                            CreateBindCtx(0, out ctx);
                            string runningObjName = string.Empty;
                            monikers[0].GetDisplayName(ctx, null, out runningObjName);
                            // when found, add the instance object to the List
                            if (runningObjName.Contains(appName))
                                object runningObjValue;
                                runningObjTable.GetObject(monikers[0], out runningObjValue);
                        return instances;


                This class finds all instances of DxDesigner (or any other application, for that matter) in the Running Object Table (ROT) and casts them to type T. It allows for the following:


                var instances = RunningObjectTable.GetInstancesWithName<ViewDraw.Application>("Viewdraw.Application");
                foreach (var instance in instances)
                    string instancePathProject = instance.GetProjectData().GetProjectFilePath();
                    if (instancePathProject == _pathProject)
                        this.Application = instance;


                Or, you could pop up a dialog asking the user which instance they'd like to "connect" to, as I do for Expedition.

                1 of 1 people found this helpful