添加到C ++应用程序C#GUI

编程入门 行业动态 更新时间:2024-10-12 10:18:40
本文介绍了添加到C ++应用程序C#GUI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想添加我的C ++应用程序一个C#.NET GUI。 我的C ++应用程序很简单,但我有一个指针和引用。

I would like to add my C++ application a C# .NET GUI . My C++ application is very simple but I have a some Pointer and Reference .

什么是最好的方法C#将识别这个指针和参考? >

What is the Best way C# will recognize this pointer and Reference?

推荐答案

有几种方法,这里有一些,这取决于你的口味和你的项目。

There are several ways, here are some, and it depends on your taste and on your project.

a)如果你的C ++项目是用COM写的,使用COM interop。

a) Use COM interop, if your C++ project is written in COM.

b)使用COM interop,

b) Use COM interop, you can write COM wrappers to your C++ application and use it from C#.

c)使用C ++ / CLI,即将项目转换为托管C ++应用程序,并使用C ++创建托管类,你的C ++代码。 您还可以编写一个托管C ++ dll加载您的C ++ dll或静态库。

c) Use C++/CLI, that is, convert your project to become a Managed C++ application and create managed classes in C++ that use your C++ code. You can also write a managed C++ dll that loads your C++ dll or static library.

d)使用P INVOKE C调用,导出DLL C函数从C ++代码,使用C ++类,使用[dllimport]属性从C#调用C函数。 你可以使用类型IntPtr和更好更安全的SafeHandle来表示指针和引用。

d) Use P INVOKE C calls, exports DLL C functions from your C++ code that work with your C++ class, call the C functions from C# using [dllimport] attribute. You can use type IntPtr and the better and safer SafeHandle to express pointers and references.

所有方法都有好的东西和缺点,但每个列出的语言需要一个中间层,你不能从C#直接调用C ++代码。

All ways have good things and drawbacks, but every listed tehcnique need a "middle layer", you cannot call C++ code directly from C#.

更多推荐

添加到C ++应用程序C#GUI

本文发布于:2023-11-12 11:06:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   GUI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!