Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8623681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:20:34+00:00 2026-06-12T07:20:34+00:00

When I create a winrt component using WRL, the problem is that I can

  • 0

When I create a winrt component using WRL, the problem is that I can only use ABI::Windows::xxx namespace, and I cannot use Windows::UI::Xaml::Media::Imaging namespace in WRL.

Then, how to create a build-in winrt component as a return value?

// 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 width, _In_ int height, _Out_ IBitmapImage **ppBitmapImage)
            {
                // How to create Windows.UI.Xaml.Media.Imaging.BitmapImage without using Windows::UI::Xaml::Media::Imaging
            }

        };

        ActivatableClass(PhotoDecoder);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:20:35+00:00Added an answer on June 12, 2026 at 7:20 am

    There are two sets of namespaces:

    • those rooted in the global namespace (e.g. Windows::Foundation)
    • those rooted in the ABI namespace (e.g. ABI::Windows::Foundation)

    The contents of each are “the same.” For example, Windows::Foundation::IUriRuntimeClass names the same interface as ABI::Windows::Foundation::IUriRuntimeClass.

    So, why are there two sets of namespaces? the namespaces rooted in the global namespace are reserved for use by C++/CX: it generates its projections of runtime classes in those namespaces. When you’re using WRL, you’ll always work with the namespaces rooted in the ABI namespace (which are the “unprojected” names, that is, they’re exactly what exist at the ABI layer).

    Runtime classes are instantiated (“activated”) in one of two ways. If the type is default constructible, it may be default constructed by calling RoActivateInstance. If a type declares other constructors, those constructors may be called by getting the activation factory for the runtime type by calling RoGetActivationFactory. As an example, you can default construct a BitmapImage like so:

    using namespace Microsoft::WRL;
    using namespace Microsoft::WRL::Wrappers;
    
    using namespace ABI::Windows::UI::Xaml::Media::Imaging;
    
    HStringReference classId(RuntimeClass_Windows_UI_Xaml_Media_Imaging_BitmapImage);
    
    ComPtr<IInspectable> inspectable;
    if (FAILED(RoActivateInstance(classId.Get(), inspectable.GetAddressOf())))
    {
        // Handle failure
    }
    
    ComPtr<IBitmapImage> bitmapImage;
    if (FAILED(inspectable.As(&bitmapImage)))
    {
        // Handle failure
    }
    

    WRL also has a useful function template, Windows::Foundation::ActivateInstance, that both calls RoActivateInstance and performs the QueryInterface to the desired target interface:

    using namespace Windows::Foundation;
    
    ComPtr<IBitmapImage> bitmapImage;
    if (FAILED(ActivateInstance(classId.Get(), bitmapImage.GetAddressOf())))
    {
        // Handle failure
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a WinRT component using C++ and WRL (Windows Runtime C++
It's been said that you can create a C++ WinRT component that you can
How I can create bitmap image from xaml control using WritableBitmapEx. In my winRT
I'm trying to create a C# WinRT component for use in metro style applications
I'd like to create a small application that can collect system information (Win32_blablabla) using
I’ve got a WinRT app that I’m using the Windows Azure Toolkit for Windows
I'm trying to create a stackpanel in WinRT that will wrap to the next
How do I create DataTemplate in win8 (WinRT) App using code behind file i.e.
I'm trying to create an ImageToggleButton for my WinRT project that changes it's image
create unique index In DB2 UDB I can create an index using the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.