本文介绍了[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!

推荐答案


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

08-20 14:05