軟件環境:
必裝項:
1、MicroFramework 4.6.2
2、MicroFrameworkSDK 4.6.2
開發流程
-
創建項目
-
編寫類和代碼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ComX
{
/// <summary>
/// 類入口
/// </summary>
[ComVisible(true)]
[Guid("3A19FC50-51B7-45D7-B837-6A061952FA53")]
[ProgId("ComX.ComDL")]
public class ComDL
{
//方法
public int CalcAdd(int A, int B)
{
return A + B;
}
}
}
-
創建Guid
-
設置項目組件屬性
-
生成com組件
-
註冊插件
-
方法
- 根據路徑和軟件環境版本按實際填寫,拷貝以下內容在cmd中執行
cd C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools
gacutil /if D:\ComX\ComX.dll
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
RegAsm D:\ComX\ComX.dll
pause
-
註冊結果
-
VBS調用
備註:單獨創建vbs有問題,但在引用的別的軟件中正常
Dim obj
Set obj = CreateObject("ComX.ComDL")
Msgbox obj.CalcAdd(1,2)
-
效果