从 C# 可执行文件启动 Windows 10 Store 应用程序 [英] Launching a Windows 10 Store app from C# executable

查看:53
本文介绍了从 C# 可执行文件启动 Windows 10 Store 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这是我的问题的要点:我有一个键盘,我可以从中分配宏和/或启动程序.我想在该列表中包含几个 Win10 和 Steam 应用程序.所以我选择构建一个可执行的启动器",可以这么说.

So here's the gist of my problem: I have a keyboard where I can assign macros and/or launch programs from. I want to include a couple Win10 and Steam applications in that list. So I opted to build an executable "launcher", so to speak.

代码本质上很简单.我通过将 Steam url 放入 Process.Start("steam://rungameid/#####") 来使 Steam url 工作.但是,我无法弄清楚如何让 Win10 应用程序工作.这是我的课程:

The code is simplistic in nature. I got Steam url's to work by placing the steam url into Process.Start("steam://rungameid/#####"). I cannot, however, figure out how to get Win10 apps to work. Here's my class:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        Process.Start(@"explorer.exe shell:AppsFolder\4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App");
        Process.Start(@"shell:AppsFolder\4DF9E0F8.Netflix_mcm4njqhnhss8!Netflix.App");
        Process.Start("netflix://");

        Application.Exit();
    }
}

Process.Start() 的每一行都是我尝试过的,但无济于事.

Each line of Process.Start() is what I've tried, to no avail.

我从这个答案尝试的底线,这也不起作用

The bottom line I attempted from this answer, which also did not work

第一行,我可以把它放在一个运行框中或从命令行 saDand 它将启动 Netflix,但从 C# 应用程序,我得到一个系统找不到文件"异常.

The first line, I can put that in a Run box or from the command line saDand it will launch Netflix, but from the C# application, I get a "System cannot find the file" exception.

感谢您的指导!

推荐答案

能否请您检查一下您是否安装了这个应用程序并且您在 Process.Start("") 中输入的名称是否正确,您可以找到名称打开注册表项 HKEY_CLASSES_ROOT\Extensions\ContractId\Windows.Protocol\PackageId.查找 CustomProperties 键.它有一个属性名称.我使用以下示例打开我的照片,效果很好.

Can you please check if you have installed this app and name you enter in the Process.Start(" ") is correct, You can find the names when you open the registry key HKEY_CLASSES_ROOT\Extensions\ContractId\Windows.Protocol\PackageId. Look for the CustomProperties key. It has an attribute Name. I use the below sample to open my photos, It works fine.

 private void Form4_Load(object sender, EventArgs e)
    {
        button2_Click(null,null);
    }
    private void button2_Click(object sender, EventArgs e)
    {
        Process.Start("ms-photos://");
    }

这篇关于从 C# 可执行文件启动 Windows 10 Store 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆