在UWP项目中引用本机C ++ dll [英] Reference native c++ dll in UWP project
问题描述
我有一个要在正在处理的UWP项目中使用的c ++ dll.我需要一些助手来实现这一目标.
I have a c++ dll that I want to utilize in the UWP project that I am working on. I need some assistant on how to achieve that.
推荐答案
通用Windows Apps在受限制的运行时环境中运行,因此,您不能像在经典Windows桌面应用程序中那样仅使用任何本机DLL.如果您具有DLL的源代码,则可以移植代码,使其在UWP上运行.首先,更改一些项目设置和项目文件元数据,以将项目标识为UWP项目.您需要使用/ZW选项编译库代码,该选项启用C ++/CX.由于与该环境相关联的更严格的控制,因此某些UWP应用中不允许使用某些API调用.请参阅适用于UWP应用程序的Win32和COM API.
Universal Windows Apps run in a restricted runtime environment, so you can't just use any native DLL the way you would in a classic Windows desktop application. If you have source code for a DLL, you can port the code so that it runs on the UWP. You start by changing a few project settings and project file metadata to identify the project as a UWP project. You need to compile the library code using the /ZW option, which enables C++/CX. Certain API calls are not allowed in UWP apps due to stricter controls associated with that environment. See Win32 and COM APIs for UWP apps.
如果您的本机DLL使用 __ declspec(dllexport)
公开功能,则可以按照
If your native DLL exposes functions using __declspec(dllexport)
, then you could follow the procedure on Using a Win32 DLL in a UWP App.
这篇关于在UWP项目中引用本机C ++ dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!