Launch apps from microsoft store on win10
-
I want to make a feature obtain all apps installed in pc and users can launch other apps from my apps.
Here is the problem I meet,There're some applications already pre-load in win10 ( or install from Microsoft store,
for example: paint3D, weather..etc)
and they all installed in a folder that the user needs permission to access this folder:"C:\Program Files\WindowsApps"
It means if I want to launch apps inside this folder, I must launch it through shell script just like:
"explorer.exe shell:appsFolder\Microsoft.BingWeather_8wekyb3d8bbwe!App"
It composed by "PackageFamilyName" ! "app ID"
but It is lots of work to get this two information from windows.Is there have a more convenient way to launch this kind of app by QT?
thanks! -
Hi, you can bypass finding the package and app ID by utilizing that MSStore apps also register themselves via a windows.protocol (a string that ends with :// like https:// etc.)
Here's an suggestion on how to enumerate them from the registry and then start them using the "://" suffix:Create an empty, vanilla Widgets app, then change your main.cpp to look like this:
#include "mainwindow.h" #include <QApplication> #include "qsettings.h" #include "qcombobox.h" #include "qpushbutton.h" #include "qprocess.h" #include "QVBoxLayout" int main(int argc, char *argv[]) { QApplication a(argc, argv); QSettings r("HKEY_CLASSES_ROOT\\Local Settings\\Software\\Microsoft\\Windows\\CurrentVersion\\AppModel\\PackageRepository\\Extensions\\windows.protocol",QSettings::NativeFormat); auto cb = new QComboBox;; cb->setEditable(false); cb->addItems(r.childGroups()); auto pb = new QPushButton; QObject::connect(pb,&QPushButton::clicked,[cb] { QProcess::startDetached("explorer " + cb->currentText() + "://"); }); auto vb = new QVBoxLayout; vb->addWidget(cb); vb->addWidget(pb); auto wi= new QWidget; wi->setLayout(vb); wi->show(); return a.exec(); }
To start for example Calculator, just scroll down to "calculator" in the combobox and press the button, voila :-)