Create a Session from an Existing Session File
This sample program uses CreateControl() to create a new session based on a saved session file. The session does not have a view associated with it and is therefore not visible. (For other ways to get terminal sessions, see Terminal and View Objects.)
To create an "existing" session
- Start Reflection 2011, create a session document, and connect to the host.
- Name, save, and then close the session document, but leave Reflection 2011 running.
- In Visual Studio, create a new Console Application project. In the New Project dialog box, type "Get Existing Session" in the Name field. Select the Create directory for solution box, click Browse to select your API projects folder (for example, C:\MyProjects), and then click OK.
- In Solution Explorer, add the class assemblies. (For instructions, see Create an API Project.)
- Copy the code from one of the following programs:
Create Session From Existing Session File (IBM)
Create Session From Existing Session File (OpenSystems)
- In Visual Studio, paste the code to the Program.cs tab, replacing all existing code.
- In the code, change the parameter for reflectionApplication.GetControlsByFilePath to the complete path of your saved session document. Between the quotation marks, type the path exactly as it appears, including the drive letter (for example, C:\), any spaces, and the filename and extension of the session document.
- Build the application (Build > Rebuild Solution) and then run it (Debug > Start Without Debugging).
A Windows command console containing a line of extracted text should appear.