如何在 Windows 10 C# 通用应用程序中使用 C++ 类? [英] How to use C++ class in Windows 10 C# universal app?

查看:37
本文介绍了如何在 Windows 10 C# 通用应用程序中使用 C++ 类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的 Windows 10 C# 通用应用程序中的 cpp 类执行一个方法.由于我是 Windows 应用程序开发和 C# 的新手,所以我可以使用一些代码来理解该方法.

I want to execute a method from cpp class in my Windows 10 C# Universal app. As i'm a newbie in Windows app development and C#, so i can use some code to understand the method.

推荐答案

您需要:
1- 使用 C++/CX
创建一个新的 Windows 通用运行时组件 DLL2- 添加一个新的 ref 类.此类将成为您的 C++ 代码的包装器.
3- 从那个新类调用你的 C++ 方法
4- 从您的 C# 项目中添加对新 DLL 的引用,并从那里使用 C++/CX 包装器类.

You need to:
1- Create a new Windows Universal Runtime Component DLL, using C++/CX
2- Add a new ref class to it. This class will be a wrapper to your C++ code.
3- Call your C++ method from that new class
4- Add a reference to the new DLL from your C# project, and use the C++/CX wrapper class from there.

这篇关于如何在 Windows 10 C# 通用应用程序中使用 C++ 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆