开发者

JavaScript convert to C#

I want to convert following Javascript function to C#. Can anyone help?

var vc = new ActiveXObject("NetLimiter.VirtualClient");
v开发者_运维百科c.Connect("localhost"/*addr*/, ""/*port or pipe*/);
var newRuleId = vc.SetRule(
    "C:\\Program Files\\Internet Explorer\\iexplore.exe",
    "limit",// rule type
    "in", // for download (incoming)
    "Internet",// zone
    true, // rule is enabled
    "1024", // 1024 Bytes
    "");


Use AutomationFactory.CreateObject:

dynamic vc = AutomationFactory.CreateObject("NetLimiter.VirtualClient");

Then everything else should be just fine.


An ActiveXObject is a COM object. You can add a refence to that COM object in your C# project, then just instantiate it in your code and call any function you need.


You would need the source for the ActiveXObject, but assuming that all the method calls were valid for that object - this would already compile in C#

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜