C#相当于VB6的的getObject [英] C# equivalent of VB6's GetObject
问题描述
下面的VB6代码连接到一些第三方软件,并强制使用管理员用户名和密码登录:
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
我想这样做在C#中相同的任务,但作为一个非常绿色的C#开发者(约3个月的经历)我不知道如何做到这一点。我花了一个非常令人沮丧的一天在谷歌,但没有发现任何适合该法案(大部分我甚至不能明白)我知道,甚至对VB6比我少约C#,但VB6使得它看起来那么容易。
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.
我也不能测试连接到该第三方软件,直到我实现了我们的QA环境。所以我想用一个简单的应用程序,记事本为例来测试功能。 /方法我可以呼吁记事本,而不是FixLogin?
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.
推荐答案
即使您正在使用C#中,您可以使用Vb.Net提供的所有类和方法,包括GetObject的。
Even if you're working with c#, you can use all classes and methods provided by Vb.Net, including GetObject.
只需添加到.NET组件Microsoft.VisualBasic程序的引用。
Just add a reference to the .NET Component "Microsoft.VisualBasic".
一旦你已经添加了引用,你可以调用
Microsoft.VisualBasic.Interaction.CreateObject()或Microsoft.VisualBasic.Interaction.GetObject()
Once you have added the reference, you are able to call Microsoft.VisualBasic.Interaction.CreateObject() or Microsoft.VisualBasic.Interaction.GetObject()
这篇关于C#相当于VB6的的getObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!