小编use*_*871的帖子

如何使用WRL返回内置winrt组件?

当我使用WRL创建winrt组件时,问题是我只能使用ABI::Windows::xxx命名空间,而且我不能Windows::UI::Xaml::Media::Imaging在WRL中使用命名空间.

那么,如何创建内置winrt组件作为返回值?

// idl
import "inspectable.idl";
import "Windows.Foundation.idl";
import "Windows.UI.Xaml.Media.Imaging.idl";

namespace Decoder
{
    interface IPhotoDecoder;
    runtimeclass PhotoDecoder;

    interface IPhotoDecoder : IInspectable
    {
        HRESULT Decode([in] int width, [in] int height, [out, retval] Windows.UI.Xaml.Media.Imaging.BitmapImage **ppBitmapImage);
    }

    [version(COMPONENT_VERSION), activatable(COMPONENT_VERSION)]
    runtimeclass PhotoDecoder
    {
         [default] interface IPhotoDecoder;
    }
}

// cpp
using namespace Microsoft::WRL;
using namespace Windows::Foundation;
using namespace ABI::Windows::UI::Xaml::Media::Imaging;
namespace ABI
{
    namespace Decoder
    {
        class PhotoDecoder: public RuntimeClass<IPhotoDecoder>
        {
            InspectableClass(L"Decoder.PhotoDecoder", BaseTrust)

            public:
            PhotoDecoder()
            {
            }

            HRESULT __stdcall Decode(_In_ int …
Run Code Online (Sandbox Code Playgroud)

c++ windows-runtime wrl

2
推荐指数
1
解决办法
3723
查看次数

标签 统计

c++ ×1

windows-runtime ×1

wrl ×1