Access list of installed apps

眉间皱痕 提交于 2020-01-11 10:35:08

问题


I need to get the installed apps of a Windows Phone. Do you know if this is available from the SDK?


回答1:


It's possible to list third party applications installed on the phone, but only from your desktop machine (ie. not from an app running on the device) and thus might not be what you are after.

Firstly, you need to add a reference to this assembly:

c:\Program Files (x86)\Common Files\microsoft shared\Phone Tools\CoreCon\10.0\Bin\Microsoft.Smartdevice.Connectivity.dll

Then the following code will connect to the emulator (useEmulator = false for a device) and writes the product IDs of all the applications installed to the console.

int locale = CultureInfo.CurrentCulture.LCID;
bool useEmulator = true;

var datastoreManager = new DatastoreManager(locale);

var phonePlatform = datastoreManager.GetPlatforms()
    .Single(p => p.Name == "Windows Phone 7");

var phoneDevice = phonePlatform.GetDevices()
    .First(d => d.IsEmulator() == useEmulator);

phoneDevice.Connect();

var apps = phoneDevice.GetInstalledApplications();

foreach(RemoteApplication app in apps)
{
    Console.WriteLine(app.ProductID.ToString());
}

phoneDevice.Disconnect();

Some caveats:

  • As previously mentioned this code runs on .NET on the desktop, not on the phone itself
  • Only ProductID is available to you, accessing Genre or Title will throw a NotImplementedException
  • I haven't included any error handling
  • This isn't an officially supported API to my knowledge and may change.



回答2:


I think it's not possible in legal way.

Each application lives in its sandbox and has no access to parent folders or other applications.




回答3:


Perhaps you could explain why you want to get this information. It may be possible to work out a solution in some circumstances, for example if you want to know if another of your apps is installed on the device. (This is unlikely to be on-device, and may rely on a web service to track your install base).

Of course, having that knowledge is not necessarily going to help you. You are not going to be able to launch the other app, or interact with it directly so it might just be a waste of time trying.




回答4:


At this point of time, there is no such API to fetch the list of installed application. More things are restricted to maintain security for the user data. :)



来源:https://stackoverflow.com/questions/8788271/access-list-of-installed-apps

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