1

首先 - 我是这个网站的新手,所以我在开始时很小心。

我的流程有问题。我想将它作为 32 - 64 位进程启动,而不仅仅是 64 位。我尝试在 AnyCPU、x64、x86 上更改 Visual Studia 2010 中的调试配置,但它不起作用。

我的代码在这里:

public static void startMinecraft(bool mode, string ramMax, string ramMin, string username, string sessionID, bool debug, string javafold, string mainfolder, string server)
        {
            string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\";
            string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\";

            Process proc = new Process();
            proc.StartInfo.UseShellExecute = false;
            if (Environment.Is64BitProcess)
            {
                MessageBox.Show("yes"); // it is always yes
            }
            else 
            {
                MessageBox.Show("no");
            }

            if (proc.StartInfo.EnvironmentVariables.ContainsKey("APPDATA"))
                proc.StartInfo.EnvironmentVariables["APPDATA"] = @appData + mainfolder + "\\" + server;
            else
                proc.StartInfo.EnvironmentVariables.Add("APPDATA", @appData + mainfolder + "\\" + server);

            if (debug == true)
            {
                proc.StartInfo.FileName = @appData + javafold + "\\jre\\bin\\java.exe";
            }
            else
            {
                proc.StartInfo.FileName = @appData + javafold + "\\jre\\bin\\javaw.exe";
            }

            //Online and offline modes
            if (mode == true)
            {
                proc.StartInfo.Arguments = "-cp \"" + appData + mainfolder + "/.minecraft/bin/minecraft.jar;" + appData + mainfolder + "/.minecraft/bin/lwjgl.jar;" + appData + mainfolder + "/.minecraft/bin/lwjgl_util.jar;" + appData + mainfolder + "/.minecraft/bin/jinput.jar;\" ";
                proc.StartInfo.Arguments += "\"-Djava.library.path=" + appData + mainfolder + "/.minecraft/bin/natives\" -Xmx" + ramMax + "M -Xms" + ramMin + "M net.minecraft.client.Minecraft " + username + " " + sessionID;
            }
            else
            {
                proc.StartInfo.Arguments = "-cp \"" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\minecraft.jar;" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\lwjgl.jar;" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\lwjgl_util.jar;" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\jinput.jar;\" ";
                proc.StartInfo.Arguments += "\"-Djava.library.path=" + appData + mainfolder + "\\" + server + "\\.minecraft\\bin\\natives\" -Xmx" + ramMax + "M -Xms" + ramMin + "M -XX:MaxPermSize=256m net.minecraft.client.Minecraft " + username;
            }
            proc.Start();
        }

此过程完美运行,但仅适用于 64 位操作系统平台。

32 位操作系统上的错误是:

System.ComponentModel.Win32Exception (0x80004005): The specified executable is not a valid application for this OS platform.
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at WindowsFormsApplication1.Form1.startMinecraft(Boolean mode, String ramMax, String ramMin, String username, String sessionID, Boolean debug, String javafold, String mainfolder, String server)
   at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) etc...

感谢大家的帮助!并为我的英语错误感到抱歉。

4

2 回答 2

2

您应该只考虑制作一个 32 位 exe,这将适用于 32 和 64

于 2013-10-22T19:37:31.537 回答
0

如果我正确解释了堆栈跟踪,则问题不在于您的应用程序,而在于您尝试执行的应用程序。因此,您的java.exe和/或javaw.exe似乎仅在 64 位上运行。

于 2013-10-30T19:29:57.187 回答