UWP:如何调用 WinAPI 方法 [英] UWP: How to call WinAPI Method
问题描述
我的问题很简单.
如何调用 WinAPI 方法,例如 emptyClipboard 在 UWP 应用中?
My question is simple.
How can I call a WinAPI Method like emptyClipboard in an UWP app?
我包含了适用于 UWP 的 Windows 桌面扩展"
I included the 'Windows Desktop Extensions for the UWP'
该方法列在 Windows API 索引/数据交换/剪贴板参考/剪贴板功能
我尝试了以下(js
):
Windows.emptyClipboard();
Windows.WinAPI.emptyClipboard();
Windows.ApplicationModel.emptyClipboard();
Windows.DataExchange.emptyClipboard();
Windows.DataExchange.Clipboard.emptyClipboard();
他们每个人都给了我以下错误(正如预期的那样):
each of them giving me the following error (as expected):
0x800a01b6 - JavaScript 运行时错误:对象不支持属性或方法emptyClipboard"
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'emptyClipboard'
推荐答案
您不能直接从通用 Windows 应用程序调用 WinAPI 函数.您必须在 Windows 运行时 (WinRT) 中找到等效功能.
You cannot call WinAPI functions directly from a Universal Windows application. You have to find the equivalent function in the Windows Runtime (WinRT).
要清除剪贴板,请使用以下代码:
To clear the Clipboard, use the follwing code:
Windows.ApplicationModel.DataTransfer.Clipboard.clear();
<小时>
当您编辑您的 UWP 应用程序项目并添加对适用于 UWP 的 Windows 桌面扩展"的引用时,您不允许该应用直接调用 WinAPI 函数,但您启用使用 Windows 运行时 (WinRT) 的一部分仅适用于台式计算机.
When you edit your UWP application project and add a reference to "Windows Desktop Extensions for the UWP", you do not allow the app to call WinAPI functions directly, but you enable using a part of the Windows Runtime (WinRT) that only makes sense on desktop computers.
这里是 仅当您引用适用于 UWP 的 Windows 桌面扩展"时才可用的 WinRT 功能列表
这篇关于UWP:如何调用 WinAPI 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!