OfflineLicensesChanged event is never raised when trial license expires for a Windows 10 Store app

家住魔仙堡 提交于 2019-12-24 08:47:19

问题


I'm trying the following code for my Win32 app converted to UWP for the Windows 10 Store. The app is posted in the store under a trial license for 7 days.

The goal of the code below is to receive a notification when the app's trial period expires:

#include <Windows.Services.Store.h>
#include <wrl.h>
#include <wrl/event.h>

//'hMainWnd' = HWND handle to the app's main window

//ComPtr<IStoreContextStatics> storeContextStatics;
//...

ComPtr<IStoreContext> storeContext;
hr = storeContextStatics->GetDefault(&storeContext);
if (SUCCEEDED(hr))
{
    EventRegistrationToken tokenLicChanged;
    hr = storeContext->add_OfflineLicensesChanged(Callback<__FITypedEventHandler_2_Windows__CServices__CStore__CStoreContext_IInspectable_t>(
        [hMainWnd](IStoreContext* storeCntx, IInspectable* pDispArgs)->HRESULT
    {
        //Must be called when store license changes

        ::MessageBox(hMainWnd, 
            L"HELL YEAH -- LICENSE CHANGE NOTIFICATION!!!", 
            L"*****LIC CHANGE Result*****",
            MB_ICONINFORMATION);

        return S_OK;
    }).Get(), &tokenLicChanged);

    if (SUCCEEDED(hr))
    {
        //Put this thread into a waiting state...

    }
    else
    {
        __assert_and_fail();
    }
}
else
{
    __assert_and_fail();
}

I let the app run and waited for the license to expire, but OfflineLicensesChanged event was never raised.

Any idea what am I doing wrong?

来源:https://stackoverflow.com/questions/40209789/offlinelicenseschanged-event-is-never-raised-when-trial-license-expires-for-a-wi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!