若该文为原创文章,转载请注明原文出处
本文章博客地址: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,如下图:
将注册的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控件》
下一篇:敬请期待…