如何将CreateObject("Wscript.shell")转换为C# [英] How to translate CreateObject("Wscript.shell") into C#

查看:65
本文介绍了如何将CreateObject("Wscript.shell")转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何用C#进行翻译?

How could i translate this in c#?

Set WshShell = WScript.CreateObject( "WScript.Shell" )

Thx.这是什么用的?为了工作,我还必须在c#中包括什么库?

Thx. At what is this used? And also what is the library i have to include in c# in order to work?

推荐答案

使用Shell对象编写脚本仍然可以轻松完成一些事情.您可以使用.p获得来自.NET的访问权限

There are still some things more easily accomplished with the Shell objects for Scripting. You can get access from .NET using

var sh = (Shell32.IShellDispatch4)Activator.CreateInstance(
                                       Type.GetTypeFromProgID("Shell.Application"));

(添加对Shell32.dll的引用以创建互操作类)

(add a reference to Shell32.dll to have the interop classes created)

这篇关于如何将CreateObject("Wscript.shell")转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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