WRL을 사용하여 winrt 구성 요소를 만들 때 ABI::Windows::xxx
네임 스페이스 만 사용할 수 있으며 WRL에서 Windows::UI::Xaml::Media::Imaging
네임 스페이스를 사용할 수 없습니다.WRL을 사용하여 build-in winrt 구성 요소를 반환하는 방법은 무엇입니까?
그런 다음 반환 값으로 빌드 윈인 구성 요소를 만드는 방법은 무엇입니까?
- 글로벌 네임 스페이스 (예 :
Windows::Foundation
) ABI
네임 스페이스에 뿌리를 둔 사람들을 뿌리들 (예를 들어ABI::Windows::Foundation
)
:
// 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);
}
}
을 고마워요.하지만 UI 스레드에서 생성 된 다른 스레드에서 ActivateInstance를 호출하면 RPC_E_WRONG_THREAD를 반환하고 인스턴스를 만들지 못했습니다. 그러나 나는 또한 다른 스레드에서'CreateStreamOverRandomAccessStream'을 호출하려고합니다. COM 객체를 생성하는 것과 유사하지만 잘 동작 할 수 있다고 생각합니다. 왜 그런지 알아? – user1713871