如何从代码以兼容模式执行程序? [英] How to execute a program in compatibility mode from code?
问题描述
环境: Windows Server 2008 R2 64位
我有一个可用于的程序Windows Server 2003 SP1 兼容模式。但是,当我尝试使用C#执行该程序时,该程序出错。
I have a program that works with Windows Server 2003 SP1 compatibility mode. However, when I try to execute this program using C#, the program errors out.
我认为这是因为从另一个程序调用时,它不在兼容模式下运行。我使用代码中的 Process.Start(pathToExe)
启动此程序。
I think it is because it is not running in compatibility mode when invoked from another program. I use Process.Start(pathToExe)
from my code to start this program.
我试图在兼容模式下运行调用程序,以检查这是否会使程序正确运行。
I tried to run the calling program in compatibility mode to check if this would make the program run correctly.
请注意,我已经从 Properties |兼容性。
推荐答案
我不确定我是否完全了解您的问题,但是您是否要运行程序始终在兼容模式下,可以设置注册表以使其正常运行。
I am not sure if I understand your problem exactly, but if you want to run the Program always in the Compatibility mode you can set the registry to make it work so.
注册表项:
HKEY_LOCAL_MACHINE\软件\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
添加新带有
名称的字符串输入:完整的应用程序路径。
类型:REG_SZ
数据:必需的兼容值。我认为这是 WIN2003
或 WIN2003SP1
。
Add a new String entry with,
Name : Your Application Path in Full.
Type: REG_SZ
Data : Required Compat Value. I think it is WIN2003
OR WIN2003SP1
in your case.
示例:
C:\Program Files\System32\Notepad.exe REG_SZ WIN2003
Example:
C:\Program Files\System32\Notepad.exe REG_SZ WIN2003
您可以检查正在运行的当前操作系统版本,并且可以在调用程序之前设置和取消设置此注册表值。
You can check for the current OS version you are running under and you can set and unset this registry value before calling the program.
这篇关于如何从代码以兼容模式执行程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!