Hi,
set desktop app and specific HWND:
<AppContainerApplication>false</AppContainerApplication>
<GenerateWindowsMetadata>true</GenerateWindowsMetadata>
WindowsRuntimeComponent1::Class1::Purchase ()
{
Windows::Services::Store::StoreContext^ storeContext;
storeContext = Windows::Services::Store::StoreContext::GetDefault ();
HWND hwnd = GetActiveWindow ();
IInitializeWithWindow* initWindow = nullptr;
HRESULT hr = reinterpret_cast<IUnknown*>(storeContext)->QueryInterface (IID_PPV_ARGS (&initWindow));
if (SUCCEEDED (hr) )
{
initWindow->Initialize (hwnd);
create_task (storeContext->RequestPurchaseAsync ("myAddonStoreID")).then ([](StorePurchaseResult^ result)
{
// .......
}, task_continuation_context::get_current_winrt_context ());
initWindow->Release ();
}
}
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.