相当于VB6和GetObject的C

相当于VB6和GetObject的C

本文介绍了相当于VB6和GetObject的C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下VB6代码连接到某些第三方软件,并使用管理员用户名和密码强制登录:

  Set obj = GetObject(,"workspace.application")obj.System.FixLogin strAdminUsername,strAdminPassword 

我想在C#中执行相同的任务,但是作为一个非常绿色的C#开发人员(大约3个月的经验),我不知道如何执行此操作.我在Google上度过了非常令人沮丧的一天,但没有找到任何符合要求的内容(其中大部分我什至无法理解),我对VB6的了解甚至比对C#的了解还少,但是VB6使其看起来如此简单./p>

此外,在实施我们的质量检查环境之前,我无法测试与该第三方软件的连接.因此,我想使用一个简单的应用程序(例如记事本)测试该功能.我可以在记事本上调用什么功能/方法,而不是"FixLogin"?

如果有人可以帮助我解决这个问题,我将不胜感激.

亲切的问候,史蒂夫.

解决方案

即使您正在使用c#,也可以使用Vb.Net提供的所有类和方法,包括GetObject.

只需添加对.NET组件"Microsoft.VisualBasic"的引用.

添加参考后,您就可以致电Microsoft.VisualBasic.Interaction.CreateObject()或Microsoft.VisualBasic.Interaction.GetObject()

The following VB6 code connects to some third party software and forces a login with the admin username and password:

Set obj = GetObject(, "workspace.application")
obj.System.FixLogin strAdminUsername, strAdminPassword

I am wanting to do the same task in C# but as a very green C# developer (about 3 months experience) I have no idea how to do this. I've spent a very frustrating day on Google but have found nothing that fits the bill (most of it I couldn't even understand) I know even less about VB6 than I do about C#, but VB6 makes it look so easy.

Also I can't test connecting to this third party software until I implement to our QA environment. So I would like to test the functionality with a simple app, Notepad for example. What function / method could I call on Notepad instead of "FixLogin"?

I would be most grateful if someone could help me with this problem.

Kind Regards,Steve.

解决方案

Even if you're working with c#, you can use all classes and methods provided by Vb.Net, including GetObject.

Just add a reference to the .NET Component "Microsoft.VisualBasic".

Once you have added the reference, you are able to callMicrosoft.VisualBasic.Interaction.CreateObject() or Microsoft.VisualBasic.Interaction.GetObject()

这篇关于相当于VB6和GetObject的C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 10:23