WScript VB到C#的转换 [英] WScript VB to C# conversion

查看:82
本文介绍了WScript VB到C#的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将VB代码转换为C#代码?

How can I convert this VB code into C# code?

Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
objExplorer.Navigate "http://www.codeguru.com/login.php"
objExplorer.Document.formName.username.value = "GavinWang"
objExplorer.Document.formName.password.value = "******"
objExplorer.Document.formName.Submit

推荐答案

只需指出,这实际上是VB经典代码.虽然我对属性和方法的帮助不大,但是您可以使用Type.GetTypeFromProgID来代表objExplorer的Type.从那里开始,我认为您必须对Marshal类做一些奇怪的事情,并查看IDispatch接口.

您可能希望研究一种替代的处理方式,或者(打包)包装脚本并使用C#从命令行调用它.我个人觉得使用前者更清洁.
Just to point out, that''s actually VB classic code. While I can''t really help much with the properties and methods, you can get the Type representing objExplorer by using Type.GetTypeFromProgID. From there, I''d think that you''d have to do some strange things with the Marshal class and look into the IDispatch interface.

You might want to look into an alternative way of doing things, or (ick) wrapping the script and calling it from the command line using C#. I''d personally find it cleaner to use the former.


这篇关于WScript VB到C#的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆