InfoConnect for Unisys
GetControlsByName Method (MyReflection)

The name of the control. To get all unnamed controls, use an empty string.
Gets the controls that match the specified control name in all instances of InfoConnect.
Public Shared Function GetControlsByName( _
   ByVal name As String _
) As Object()
Dim name As String
Dim value() As Object
value = MyReflection.GetControlsByName(name)
public static object[] GetControlsByName( 
   string name


The name of the control. To get all unnamed controls, use an empty string.

Return Value

An array of controls that match the specified control name. If an empty string is passed as the name, an array of unnamed controls is returned.
This sample shows how to get all of the unnamed controls in an instance of InfoConnect and then find specific controls.
//This sample gets all of the unnamed terminal controls running in an instance of InfoConnect.
//Before you run this sample, make sure at least one session is running in a InfoConnect workspace. 
//If more than one instance of InfoConnect is running, the session must be running in the first instance that was started.
using System;
using System.Collections.Generic;
using System.Text;
using Attachmate.Reflection.Framework;
using Attachmate.Reflection.Emulation.IbmHosts;
using Attachmate.Reflection.Emulation.OpenSystems;

namespace ConnectToASession
    class Program
        static void Main(string[] args)
            //Get a handle to the first Application instance started manually.
            //For production code, use a try catch block here to handle a System Application Exception thrown
            //if the app isn't running.
            Application app = MyReflection.ActiveApplication;

            //Get all of the terminal controls that are not named
            object[] terminals = app.GetControlsByName("");

            //Check to make sure at least one session is running.
            if (terminals != null && terminals.Length > 0)
                //Find terminals based on terminal type and host address
                foreach (Object terminal in terminals)

                    if (terminal.ToString().Contains("Ibm")) 
                        IIbmTerminal terminalIBM = (IIbmTerminal)terminal;

                        //Find specific terminals based on host address
                        //Then get connection status, get text from the screen, or perform other tasks


                    if (terminal.ToString().Contains("OpenSystems"))
                        ITerminal terminalOS = (ITerminal)terminal;

                        IConnectionSettingsTelnet conn = terminalOS.ConnectionSettings as IConnectionSettingsTelnet;

                        if (conn != null)
                            Console.WriteLine(((terminalOS.ConnectionSettings as IConnectionSettingsTelnet).HostAddress));



See Also