概要
vbsの作法、調べてみた。
comサーバやってみた。
参考にしたページ
環境
- windows10 home
サンプルコード
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Sample
{
[ComVisible(true)]
[Guid("C699A6A5-D3D5-4A6F-AAC0-C8E45EA2C326")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface ITest {
void Hello(string msg);
}
[ComVisible(true)]
[Guid("357D2C12-8FD1-41F8-AFCE-A513026666B0")]
[ProgId("Sample.Test")]
[ClassInterface(ClassInterfaceType.None)]
public class Test : ITest {
public void Hello(string msg) {
MessageBox.Show(msg, "Test");
}
}
}
手順
csc -target:library sample.cs
regasm /codebase sample.dll
確認
vbs
Dim o
Set o = CreateObject("Sample.Test")
o.Hello("hello, VBScript")
Set o = Nothing
以上。