Get Installed win32 application

放肆的年华 提交于 2019-12-22 01:33:05

问题


Is there any way to get installed win32 applications in UWP project?(since in uwp project I am unable to add reference of wmi call and registry).If so how it is achieved ?


回答1:


Classical win32 application can get installed win32 applications on the device by reading the registry. But in a store app, in short answer, it cannot. A store app runs in an isolated sandbox and cannot read the system level registry. For details reasons about why store app doesn't support access the registry please reference this thread.

However, if you don't want upload your app to windows store, you can try out the Brokered Windows Runtime Components for side-loaded Windows Store apps. Essentially, it allows you UWP app to call Win32 API hosted in a different process, which runs outside of the App container.

For brokered WinRT component template for VS2015 you can download here.

For more details and sample about Brokered Windows Runtime Components please reference this video and this document.




回答2:


Is there any way to get installed uwp application in the system? I tried with PackageManager class bt it does not works.Is there some other way?.I dont want to use powershell.

For getting installed store apps, I have tested PackageManager class on my side. It did work well and as far as I know it is the best way to got installed store apps. Code as follows:

var packageManager = new PackageManager();
IEnumerable<Windows.ApplicationModel.Package> packages = (IEnumerable<Windows.ApplicationModel.Package>)packageManager.FindPackagesForUser("");
var list = packages.ToList();

Pay attention that these code running on uwp require packageManagement restricted capability. More details about special and restricted capabilities this. And your app cannot be uploaded to windows store.

For using this code in traditional Win32 project just referernce the sample in this document.



来源:https://stackoverflow.com/questions/41156998/get-installed-win32-application

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