我正在为IBM 2014年的Attachmate反射编写外部应用程序,在该应用程序中,我试图使用现有会话文件创建反射应用程序。应用程序正在成功创建,但它对用户不可见,我尝试了几种方法,但没有运气。
如果有人这样做了,或者知道需要做什么来使终端可见,请回复。
下面是我使用的一段代码,
using Attachmate.Reflection;
using Attachmate.Reflection.Framework;
using Attachmate.Reflection.Emulation.IbmHosts;
using Attachmate.Reflection.UserControl.IbmHosts;
using Attachmate.Reflection.UserInterface;
Application reflectionApplication;
reflectionApplication = MyReflection.CreateApplication("app", true);
IIbmTerminal terminal =(IIbmTerminal)reflectionApplication.CreateControl(@"C:mypathtest.rd3x");
reflectionApplication = MyReflection.ActiveApplication;
IFrame frame = (IFrame) reflectionApplication.GetObject("Frame");
frame.Visible = true;
做到这一点的最佳方法是利用现有的会话文件(通常在Reflection中加载)。这样,您就不必担心主机名,端口通过代码。
这是一个样板,我已经成功地使用过了。
Attachmate.Reflection.Framework.Application reflectionApplication = null;
reflectionApplication = MyReflection.CreateApplication("myWorkspace", true);
if (reflectionApplication != null)
{
IIbmTerminal terminal = (IIbmTerminal)reflectionApplication.CreateControl(
@"C:ProgramDataAttachmateReflection<your session file>.rd3x");
if (terminal != null)
{
terminal.Connect();
//You can also use AfterConnect event to wait for the connection.
while (!terminal.IsConnected)
{
System.Threading.Thread.Sleep(500);
}
IView sessionView;
IFrame theFrame = (IFrame)reflectionApplication.GetObject("Frame");
sessionView = theFrame.CreateView(terminal);
IIbmScreen screen = terminal.Screen;
screen.WaitForHostSettle(6000, 3000);
}
else
Console.WriteLine("Can not create the control.");
}
else
Console.WriteLine("Failed to get Application object.");