简体   繁体   English

如何从Windows应用商店应用启动桌面应用?

[英]How to launch a desktop application from windows store apps?

Please tell me how we can launch a desktop application or .exe file from a Windows store app using c#. 请告诉我如何使用c#从Windows应用商店应用启动桌面应用程序或.exe文件。

Any help would be really appreciated. 任何帮助将非常感激。 Thanks in Advance! 提前致谢!

As stated in the comments, you can't directly launch an executable from a Windows Store App because of the sandboxed environment. 如评论中所述,由于沙箱环境,您不能直接从Windows Store App启动可执行文件。 However, you can use the launcher API to start an executable associated with a file. 但是,您可以使用启动器 API启动与文件关联的可执行文件。 Therefore, you could create a file association between a custom file extension and the application you want to launch. 因此,您可以在自定义文件扩展名和要启动的应用程序之间创建文件关联。 Then, just use the launcher API to open a file having the custom file extension. 然后,只需使用启动器API打开具有自定义文件扩展名的文件。

public async void DefaultLaunch()
{
   // Path to the file in the app package to launch
   string imageFile = @"images\test.png";

   var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);

   if (file != null)
   {
      // Launch the retrieved file
      var success = await Windows.System.Launcher.LaunchFileAsync(file);

      if (success)
      {
         // File launched
      }
      else
      {
         // File launch failed
      }
   }
   else
   {
      // Could not find file
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从桌面运行Windows应用商店应用程序 - Run Windows Store Application from Desktop Windows应用商店应用程序-检测应用程序的首次启动 - Windows store apps - detect first launch of the app 如何从另一个桌面应用程序控制Windows服务 - How to control of windows service from a another desktop apps 如何从hWnd获取Windows 10商店应用程序的“应用程序名称”(例如Edge) - How to get the “Application Name” from hWnd for Windows 10 Store Apps (e.g. Edge) 从应用程序内部检查Windows Store应用程序的更新 - Checking for updates to Windows Store apps from within the application 从Silverlight应用程序启动远程桌面 - Launch Remote Desktop from Silverlight Application UWP 使用 Windows 桌面扩展在提交到存储时在启动时崩溃 - UWP using Windows Desktop Extension Crashes at Launch when Submitting to Store 在C#中启动Windows应用商店应用 - Launch Windows Store Application in C# Window Store Apps(Windows 10)如何获取当前的桌面墙纸图像? - Window Store Apps (Windows 10) How to get current desktop wallpaper image? 如何在 Windows 服务的应用程序中启动 windows 表单? - How to launch a windows form in an application from Windows service?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM