Process.Start() 模拟器和命令行

Process.Start() Emulator and command line

提问人:Arthur Valenca 提问时间:2/17/2023 最后编辑:Arthur Valenca 更新时间:7/23/2023 访问量:92

问:

我正在使用 .启动进程以运行模拟器和模拟器打开游戏的命令行,但是当我运行它时,它会打开模拟器,但没有命令行和在列表框中选择的游戏,有人会对此命令行有任何想法。

命令行参数: -L “核心\genesis_plus_gx_libretro.dll”

private void StartGame()
{
   string rom = @"ROMFILES\" + RomfilesList.Text.ToString() + ".zip".ToString();
   string emulator = @"EMULATOR\retroarch.exe";
   string commandline = @"-L cores\genesis_plus_gx_libretro.dll" + rom;

   if (!File.Exists(emulator))
   {
      MessageBox.Show("Emulator is required to continue.", "ERROR", MessageBoxButtons.OK,MessageBoxIcon.Error);
   }

   if (File.Exists(emulator))
   {
      Process.Start(emulator, "\"" + commandline);
   }
}
C -3.0 C#-2.0

评论

0赞 Tu deschizi eu inchid 2/17/2023
以下内容可能会有所帮助:stackoverflow.com/a/75465116/10024425。另请参阅 ProcessStartInfo.Arguments
0赞 Jim Mischel 2/17/2023
就目前而言,您的命令行将是“-L cores\genesis_plus_gx_libretro.dllROMFILES\...”。你肯定需要在“dll”和“ROMFILES”之间留出一个空格。所以,你的双重检查有点奇怪。为什么不直接调用并处理返回的错误(或引发的异常)(如果它不成功?根本不需要检查。File.ExistsProcess.StartFile.Exists

答:

0赞 Ayman Alhaj 7/23/2023 #1

看起来在构造命令行字符串时存在一个小问题。命令行变量在内核路径和 ROM 文件之间缺少空格。

试试这个

private void StartGame()
{
   string rom = @"ROMFILES\" + RomfilesList.Text.ToString() + ".zip";
   string emulator = @"EMULATOR\retroarch.exe";
   string corePath = @"cores\genesis_plus_gx_libretro.dll";
   string commandline = "-L \"" + corePath + "\" \"" + rom + "\"";

   if (!File.Exists(emulator))
   {
      MessageBox.Show("Emulator is required to continue.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
   }
   else
   {
      Process.Start(emulator, commandline);
   }
}