是否可以从网页启动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.
对其他两篇文章进行了一些混搭[ 2 ].
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);
}
}