gpt4 book ai didi

c# - 当项目设置为 x86 时,在 C# 中启动 x64 Windows 应用程序

转载 作者:行者123 更新时间:2023-11-30 16:33:38 25 4
gpt4 key购买 nike

我正在尝试启动 osk.exe,但我不断收到“无法启动 osk”消息。问题是我的项目设置为 x86(我使用的是 ms access 数据库)。如果我切换到 x64 或任何 CPU,一切正常,但数据库将不再工作。我试过了

using System.Diagnostics;

private void btnOSK_Click(object sender, EventArgs e)
{ Process.Start("osk.exe");

Process.Start(@"C:\windows\system32\osk.exe");
}

我也试过运行 SysWOWW\osk 但这也没有用。此外,我的应用程序应该在 x86 和 x64 机器上运行。有什么办法可以绕过这个吗?真令人沮丧。

最佳答案

我找到了。感谢您的回答。

static void StartOSK()
{
string windir = Environment.GetEnvironmentVariable("WINDIR");
string osk = null;

if (osk == null)
{
osk = Path.Combine(Path.Combine(windir, "sysnative"), "osk.exe");
if (!File.Exists(osk))
{
osk = null;
}
}

if (osk == null)
{
osk = Path.Combine(Path.Combine(windir, "system32"), "osk.exe");
if (!File.Exists(osk))
{
osk = null;
}
}

if (osk == null)
{
osk = "osk.exe";
}

Process.Start(osk);
}

关于c# - 当项目设置为 x86 时,在 C# 中启动 x64 Windows 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2969515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com