在VBScript中使用的DLL [英] Using DLLs in VBScript

查看:420
本文介绍了在VBScript中使用的DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编译的C#代码放到一个DLL,但他们缺乏经验。我的C#代码包含一个类的HelloWorld 用静态方法打印()。我想利用这个DLL在VBScript中调用的方法打印()。我知道这是基础,但我以此作为将被编译到底DLL中规模较大的项目进行测试。什么是申报的样子了这一点,怎么会在方法调用看看?

I've compiled C# code into a DLL, but have little experience with them. My C# code contains a class HelloWorld with a static method Print(). I'd like to use this DLL in VBScript to call the method Print(). I know this is base, but I'm using this as a test for a larger scale project that will be compiled to DLL in the end. What's the declare look like for that and how would the method call look?

推荐答案

如果您的DLL是在系统中注册,使用的CreateObject 与它的进程id。

If your dll is registered with the system, use CreateObject with it's ProgID.

Set myObject = CreateObject("MyReallyCoolObject.HelloWorld")
myObject.Print

如果你的对象未注册系统上,使用 GetObject的带至包含对象的文件的路径。确保你的对象公开正确的接口。 (第二个参数是可选的。在这里,如果你的对象了多于一个,你可以提供一个类名。)

If your object is not registered on the system, use GetObject with a path to the file containing your object. Make sure your object exposes the proper interface. (The second parameter is optional. Here you can provide a class name if your object exposes more than one.)

Set myObject = GetObject("C:\some\path\helloworld.dll", "appname.HelloWorld")
myObject.Print

这篇关于在VBScript中使用的DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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