CreeperInATardis
CreeperInATardis

Reputation: 93

Start Windows 8 app from code in C#

So, I'm trying to make a universal speech control kind of an app (in windows forms). I'm wondering if it's possible to start a Windows 8 app from code. I'm guessing that System.Diagnostics.Process.Start wouldn't work, because when I've tried running a windows 8 app from the executable, it wouldn't start, saying it "needed to be started from a frame" (I think, I'm recalling from memory). Any ideas here?

Thanks!

Upvotes: 0

Views: 200

Answers (2)

CreeperInATardis
CreeperInATardis

Reputation: 93

I found the answer to my own question, actually. There is a command called Start that actually does this. For example, I just did "Start MicrosoftMusic:" and that did the trick (yes the colon is there on purpose).

Upvotes: 2

Cyprien Autexier
Cyprien Autexier

Reputation: 1998

I had the code to perform it using the development simulator but it won't help you. However I did some search and I found this : IApplicationActivationManager::ActivateApplication in C#?

This looked very familiar because it is quite the same API as my simulator code. I haven't tested it but you should definitely give it a try.

One last thing you might struggle with is this "AppUserModelId" thing. Going through the registry manually is not something very easy. It becomes easier with that kind of code :

RegistryKey packageKey = Registry.ClassesRoot.OpenSubKey(@"ActivatableClasses\Package");
appKey = packageKey.OpenSubKey(packageKey.GetSubKeyNames().First(x => x.StartsWith(appName)));
var serverNameKey = appKey.OpenSubKey(@"ActivatableClassId\App");
var serverName = (string)serverNameKey.GetValue("Server");
var serverKey = appKey.OpenSubKey("Server\\" + serverName);
var AppUserModelId = (string)serverKey.GetValue("AppUserModelId");

Upvotes: 1

Related Questions