关于c#:Qt开发Activex笔记三C调用Qt开发的Activex控件

2次阅读

共计 1375 个字符,预计需要花费 4 分钟才能阅读完成。

若该文为原创文章,转载请注明原文出处
本文章博客地址:https://blog.csdn.net/qq21497936/article/details/113789727

长期继续带来更多我的项目与技术分享,征询请加 QQ:21497936、微信:yangsir198808

红瘦子 (红模拟) 的博文大全:开发技术汇合(蕴含 Qt 实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬联合等等)继续更新中…(点击传送门)

Qt 开发专栏:开发技术

上一篇:《Qt 开发 Activex 笔记(二):Qt 调用 Qt 开发的 Activex 控件》
下一篇:敬请期待 …

前言

  开发 Activex 控件,以供其余应用程序调用,本篇章解说 C# 调用 Activex 控件,不限于 Qt 开发的 Activex 控件。
  Wpf 要调用 Activex 控件,必要先用 C# 对 Activex 控件进行包装,而后提供给 Wpf 调用。

Demo

  

C# 调用 Activex 办法

步骤一:注册 activex 控件

  运行之前先要注册,应用 Qt 下自带的 idc 注册一下。

idc -regserver activeHelloWorldDemo.dll

  

步骤二:确认 activeQt 控件的 clsid

  查看一下,关上注册表并搜寻一下,确认 clsid,如下图:
  

"2F12BFB8-137D-4DC2-9A93-634EFE5A6DFC"

步骤三:创立 c# 我的项目,引入 com 的 dll

  将注册的 dll 引入到我的项目中,如下图:
  

  
  

步骤四:代码中应用控件

  

步骤五:编写代码

private void button1_Click(object sender, EventArgs e)
{activeHelloWorldDemoLib.activeHelloWorldDemo dlg = new activeHelloWorldDemoLib.activeHelloWorldDemo();
    dlg.show();}

源码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace trainSimulationDemo
{
    public partial class Form1 : Form
    {public Form1()
        {InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        { }

        private void button1_Click(object sender, EventArgs e)
        {activeHelloWorldDemoLib.activeHelloWorldDemo dlg = new activeHelloWorldDemoLib.activeHelloWorldDemo();
            dlg.show();}
    }
}

上一篇:《Qt 开发 Activex 笔记(二):Qt 调用 Qt 开发的 Activex 控件》
下一篇:敬请期待 …

正文完
 0