1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

vbsの作法 その50

Last updated at Posted at 2022-01-20

概要

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



以上。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?