[UWP] [桌面桥]。帮助激活WRL存储 [英] [UWP] [Desktop Bridge].help with WRL store activation

查看:74
本文介绍了[UWP] [桌面桥]。帮助激活WRL存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在stackoverflow中找到了一些代码(如果darn论坛允许的话,我会向你展示链接:)检查试用版/许可证状态。它就像这样

I found some code in stackoverflow (I would have showed you the link if the darn forum allowed it :) that checks for trial/license status. It goes like this

void CheckIsTrial(std::function<void(bool)> onCompleted)
{
    ComPtr<IStoreContextStatics> storeContextStatics;
    auto hr = RoGetActivationFactory(HStringReference(L"Windows.Services.Store.StoreContext").Get(), __uuidof(storeContextStatics), &storeContextStatics);

    ComPtr<IStoreContext> storeContext;
    hr = storeContextStatics->GetDefault(&storeContext);

    ComPtr<IAsyncOperation<StoreAppLicense*>> getLicenseOperation;
    hr = storeContext->GetAppLicenseAsync(&getLicenseOperation);

    hr = getLicenseOperation->put_Completed(Callback<Implements<RuntimeClassFlags<ClassicCom>, IAsyncOperationCompletedHandler<StoreAppLicense*>, FtmBase>>(
        [onCompleted{ std::move(onCompleted) }](IAsyncOperation<StoreAppLicense*>* operation, AsyncStatus status)
    {
        if (status != AsyncStatus::Completed)
        {
            // It failed for some reason. Find out why.
            ComPtr<IAsyncInfo> asyncInfo;
            auto hr = operation->QueryInterface(__uuidof(asyncInfo), &asyncInfo);

            HRESULT errorCode;
            hr = asyncInfo->get_ErrorCode(&errorCode);

            // Do something with the errorCode

            // Return once error is handled
            return S_OK;
        }

        ComPtr<IStoreAppLicense> appLicense;
        auto hr = operation->GetResults(&appLicense);

        boolean isActive, isTrial = false;

        hr = appLicense->get_IsActive(&isActive);

        if (isActive)
        {
            hr = appLicense->get_IsTrial(&isTrial);
        }

        onCompleted(static_cast<bool>(isActive));
        return S_OK;
    }).Get());
}

它必须来自vs2015,因为它不会在我的vs2013上编译。编译器不喜欢lambda中的部分

It must be from vs2015 because it won't compile on my vs2013. The compiler doesn't like the part inside the lambda

[onCompleted {std :: move(onCompleted)}]

[onCompleted{ std::move(onCompleted) }]

错误C2143:语法错误:在'{'

error C2143: syntax error : missing ']' before '{'

之前缺少']'作为一个直接的win32家伙我对winrt,wrl及其他所有人都不太了解它,我只需要编译这段代码!你能告诉我如何更改lambda以便vs2013能理解吗?

Being a straight win32 guy I don't know much about winrt, wrl and all the rest of it, I just need this code to compile! Can you tell me how to change the lambda so that vs2013 will understand it?

谢谢

PS。对于设计论坛规则的天才:来自实时MSDN订阅的帐户/电子邮件不是垃圾邮件发送者,因此如果我们需要粘贴URL,请让我们这样做!

PS. To the geniuses that designed the forum rules: accounts/emails from live MSDN subscriptions aren't spammers so if we need to paste a URL please let us do so!

推荐答案

嗨deskrule,



我看到你使用过这个API
Windows.Services.Store.StoreContext
  in您的代码,基于msdn文档,我们可以看到这个Windows.Services.Store.StoreContext API仅在14393之后支持。我想知道您是否在Visual Studio 2013中使用过Windows 14393 SDK,另外,
it建议使用带有Windows 10周年更新SDK的Visual Studio 2015 Update 3,同时构建14393。



最好的问候,

David
Hi deskrule,

I see that you have used this API Windows.Services.Store.StoreContext  in your code, based on the msdn document, we can see that this Windows.Services.Store.StoreContext API is only supported after 14393. I wonder if you have used windows 14393 SDK within your Visual Studio 2013, besides, it is recommned to use the Visual Studio 2015 Update 3 which has the Windows 10 Anniversary Update SDK, build 14393 along with it.

Best Regards,
David


这篇关于[UWP] [桌面桥]。帮助激活WRL存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆