Jac*_*Dev 15 c# windows microsoft-metro windows-8
有没有办法从Windows 8上的Metro风格的应用程序启动桌面应用程序?我正在尝试为桌面应用程序创建一些简单的快捷方式,以替换开始屏幕上的桌面图标,这些图标看起来不合适.
我只需要一些非常简单的东西,最好是在C#中,一旦应用程序加载就打开一个应用程序.我打算为一些游戏,photoshop等制作这些快捷方式,而不是我自己制作的任何东西.它们也仅供个人使用,因此我可以使用直接路径来应用"C:\Program Files (x86)\Steam\steamapps\common\Skyrim\TESV.exe"
Nir*_*ngh 21
如果您只想运行像(记事本,wordpad,Internet Explorer等)的桌面应用程序,那么请通过Process Methods和ProcessStartInfo类
try
{
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "C:\Path\To\App.exe";
p.Start();
}
Run Code Online (Sandbox Code Playgroud)
// Exp 2
// Uses the ProcessStartInfo class to start new processes,
// both in a minimized mode.
void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
}
Run Code Online (Sandbox Code Playgroud)
在Windows 8 Metro应用程序中,我发现了这一点:如何从Metro App启动外部程序.
所有Metro风格的应用程序都在高度沙盒环境中工作,无法直接启动外部应用程序.
您可以尝试使用Launcher类 - 根据您的需要,它可能为您提供可行的解决方案.
检查一下:
我可以使用Windows.System.Launcher.LauncherDefaultProgram(Uri)调用另一个metro风格的应用程序吗?
Metro IE是一款特殊应用.您无法从Metro风格的应用程序调用可执行文件.
试试这个 - 我还没有测试但可能会帮助你...
// Path to the file in the app package to launch
string exeFile = @"C:\Program Files (x86)\Steam\steamapps\common\Skyrim\TESV.exe";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(exeFile);
if (file != null)
{
// Set the option to show the picker
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
bool success = await Windows.System.Launcher.LaunchFileAsync(file, options);
if (success)
{
// File launched
}
else
{
// File launch failed
}
}
Run Code Online (Sandbox Code Playgroud)
小智 12
我找到了一个适合我的解决方案.我只是在我的应用程序中创建了一个空文本文件并调用它launcher.yourappyouwanttostart
然后执行它
Windows.System.Launcher.LaunchFileAsync("launcher.yourappyouwanttostart");
Run Code Online (Sandbox Code Playgroud)
在第一次启动时,它会要求您提供此文件的关联,然后选择要运行的exe文件,从现在开始,每次执行此文件时,您的应用程序都将启动.
归档时间: |
|
查看次数: |
30378 次 |
最近记录: |