7

假设我在 Windows 8+ 上并且我有一个 Win32/C 应用程序。我的 Win32 应用程序可以调用 WinRT API 吗?

4

1 回答 1

6

Short answer - yes: How to: Activate and Use a Windows Runtime Component Using WRL

Long answer: Windows Runtime is heavily based upon COM technology. The Windows Runtime components are actually some kind of COM objects. So the common rules for instantiating and using COM objects apply to Windows Runtime components.

First, you must initialize the Windows Runtime environment. There's a useful class called RoInitializeWrapper you can use to do this. Then, you use an activation factory to obtain a pointer to the Windows Runtime component's interface. You work with the interface, and when you finished, you must uninitialize the Windows Runtime environment by destroying your RoInitializeWrapper.

于 2014-09-17T07:11:30.243 回答