开发者

C# equivalent of VB6's GetObject

开发者 https://www.devze.com 2023-01-17 08:05 出处:网络
The following VB6 code connects to some third party software and forces a login with the a开发者_Python百科dmin username and password:

The following VB6 code connects to some third party software and forces a login with the a开发者_Python百科dmin 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()


Marshal.GetActiveObject Method


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

0

精彩评论

暂无评论...
验证码 换一张
取 消