我正在尝试编写代码,该代码是Windows store中可用的检查更新,然后从那里下载。我正在使用c ++,因此我想使用此页面https://docs.microsoft.com/ru-ru/windows/uwp/packaging/self-install-package-updates中的代码,尤其是方法
公共异步任务DownloadAndInstallAllUpdatesAsync()
在那里进行了描述,但是我未能将其转换为C ++。我做了这样的事情:
.h
Windows::Services::Store::StoreContext^ context = nullptr;
Concurrency::task<Windows::Foundation::Collections::IVectorView<Windows::Services::Store::StorePackageUpdate ^> ^> updatesTask;
void DownloadAndInstallAllUpdatesAsync();
.cpp
void myApp::DownloadAndInstallAllUpdatesAsync()
{
if (context == nullptr)
context = StoreContext::GetDefault();
// Get the updates that are available.
updatesTask = create_task(context->GetAppAndOptionalStorePackageUpdatesAsync());
std::this_thread::sleep_for(std::chrono::seconds(2));
updatesTask.then([this](IVectorView<StorePackageUpdate^>^ const &update) {
if (update->Size > 0) {
// Download and install the updates.
IAsyncOperationWithProgress<StorePackageUpdateResult^, StorePackageUpdateStatus>^ downloadOperation =
context->RequestDownloadAndInstallStorePackageUpdatesAsync(update);
}
});
}
但是我在使用此代码时遇到了两个麻烦:
预先感谢您的帮助