简体   繁体   中英

C# equivalent of VB6's 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 call Microsoft.VisualBasic.Interaction.CreateObject() or Microsoft.VisualBasic.Interaction.GetObject()

GetObject returns a COM control. You'd have to work with COM Interop to do this in C#. (This isn't trivial.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM