是否可以从网页启动Silverlight 4 OOB应用程序? [英] Is it possible to launch a Silverlight 4 OOB application from a web page?

查看:78
本文介绍了是否可以从网页启动Silverlight 4 OOB应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正计划构建一个下载管理器应用程序,并希望能够在用户单击站点按钮时启动该应用程序.该应用程序显然已经需要安装在客户端计算机上.

I'm planning to build a download manager application and would like to be able to launch the application when a user clicks a button the site. The application would obviously already need to be installed on the client machine.

出于某些原因,需要使用Silverlight编写此代码,但它们与该问题并没有真正的关系.我只提到它,以便人们不建议我使用另一种技术.

There are a few reasons why this needs to be written using Silverlight, but they're not really relevant to the question. I only mention it so that people don't suggest that I use another technology.

推荐答案

对其他两篇文章进行了一些混搭[

Doing a bit of a mash up from two other posts [1] and [2].

但是,这当然仅适用于Windows,不适用于Mac.在那里,您将不得不退回到

But of course this will only work for Windows not Mac. There you will have to fallback to the @michael-s-scherotter style solution.

private void Button_Click(object sender, RoutedEventArgs e)
{
    if (Application.Current.HasElevatedPermissions && System.Windows.Interop.ComAutomationFactory.IsAvailable)
    {

        string run = "\""%ProgramFiles%\\Microsoft Silverlight\\sllauncher.exe"\" /emulate:"Silverface.xap" /origin:\"http://www.silverlight.net/content/samples/apps/facebookclient/ClientBin/Silverface.xap\" /overwrite";
        dynamic cmd = ComAutomationFactory.CreateObject("WScript.Shell");
        cmd.Run(run, 1, true);

    }
}

这篇关于是否可以从网页启动Silverlight 4 OOB应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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