views:

85

answers:

2

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.

+1  A: 

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

David Pfeffer
+3  A: 

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()

Andrea Parodi
+1, way to do it. CreateObject() does a pretty non-trivial job.
Hans Passant