首先 - 我是這個網站的新手,所以我很在意這個問題。如何以32位運行進程(應用程序不適用於32位操作系統)
我的程序有問題。我想以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...
感謝所有幫助!對於我的英語錯誤感到抱歉。
您無法在32位操作系統上運行64位進程。你不能神奇地將64位EXE轉換爲32位EXE。 – SLaks
您應該安裝32位JRE。 – SLaks