我必须将vb6程序迁移到C#.net 3.5
用户启动SAP登录并进行身份验证,
然后他可以使用该工具使用该工具获取和插入数据
问题:
我可以使用反射创建一个新的GuiApplication,但我无法用它来获取当前打开的GuiSessions:/
这是当前打开GuiApplication所有打开的GuiSessions的代码的vb6部分
用户启动SAP登录并进行身份验证,
然后他可以使用该工具使用该工具获取和插入数据
问题:
我可以使用反射创建一个新的GuiApplication,但我无法用它来获取当前打开的GuiSessions:/
这是当前打开GuiApplication所有打开的GuiSessions的代码的vb6部分
Dim obj As Object Set obj = CreateObject("SAPGUI") Set obj = obj.GetScriptingEngine If TypeName(obj) = "GuiApplication" Then Set SapAutomationObject = obj SapAutomationObject.AllowSystemMessages = False Debug.Print "SAP Automation OK" End If
我试着反思:
GuiApplication Application = (GuiApplication)System.Activator.CreateInstance(Type.GetTypeFromProgID("SapGui.ScriptingCtrl.1"));
我有一个实例,但没有现有的会话
public static void testConnection() { SapROTWr.CSapROTWrapper sapROTWrapper = new SapROTWr.CSapROTWrapper(); object SapGuilRot = sapROTWrapper.GetROTEntry("SAPGUI"); object engine = SapGuilRot.GetType().InvokeMember("GetSCriptingEngine",System.Reflection.BindingFlags.InvokeMethod,null,SapGuilRot,null); SAPconnection.sapGuiApp = engine as GuiApplication; GuiConnection connection = sapGuiApp.Connections.ElementAt(0) as GuiConnection; GuiSession session = connection.Children.ElementAt(0) as GuiSession; MessageBox.Show(session.Info.User + " !!||!! " + session.Info.Transaction); }