InfoConnect for Airlines
CreateApplication() Method
Example 


Creates an application that represents the instance of InfoConnect that was just started by you, or a InfoConnect instance running at the default IPC channel (if the InfoConnect instance is the first instance started manually).
Syntax
'Declaration
 
Public Overloads Shared Function CreateApplication() As Application
'Usage
 
Dim value As Application
 
value = MyReflection.CreateApplication()
public static Application CreateApplication()

Return Value

An Application object.
Example
This sample gets a handle to an application that represents the first instance of InfoConnect started manually. Then it gets a handle to a demo session and gets some text from a session screen. Before running this sample, make sure the demoSession.rd3x session is running in a workspace
//This sample gets the Terminal control of a running session.
//Before you run this sample, make sure the session used in GetControlsByFilePath()
//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;
namespace ConnectToASession
{
    class Program
    {
        static void Main(string[] args)
        {
            //Get a handle to an application that represents the first instance of InfoConnect 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.CreateApplication();

            //Get the terminal from the session document file path.
            string sessionPath = Environment.GetEnvironmentVariable("USERPROFILE") + @"\Documents\Micro Focus\InfoConnect\demoSession.rd3x";
            object[] terminals = app.GetControlsByFilePath(sessionPath);

            //Check to make sure the session is running.
            if (terminals != null && terminals.Length > 0)
            {
                //Get a screen and then get some text from the screen.
                IIbmTerminal terminal = (IIbmTerminal)terminals[0];
                IIbmScreen screen = terminal.Screen;
                string text = screen.GetText(18, 2, 48);
                Console.WriteLine(text);
            }
            else
                Console.WriteLine("No such control exists. Check to make sure that the session from the file is running.");

        }
    }
}
See Also