程序是否以兼容模式运行

use*_*939 6 c++

是否有我可以调用的C++ .NET函数,它将检测我的程序是否在兼容模式下运行?如果没有,有人可以给我一个代码吗?谢谢.

例如:

程序加载兼容模式检查是否为true然后退出else运行

Eto*_* B. 9

From another forum

After a few google searches went in vain, I decided to experiment myself. I found that the compatibility settings for each executable are stored - as I thought it would be - in the windows registry.

The key where the settings are stored is
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

For each application that has its compatibility settings specified, there exists a value under that key whose name is the path to the executable and the data is a string consisting of the compatibility settings.

The keywords in the string that specify the compatibility settings are: WIN95 WIN98 NT4SP5
WIN2000 256COLOR 640X480
DISABLETHEMES DISABLECICERO

如果指定了多个设置(或要指定),则数据由上面的设置组成,每个设置用空格分隔.前四个设置是互斥的,即只指定其中一个(如果有的话).我没有测试指定多个操作系统的后果.

So, back to addressing your problem. To check if an executable (let's say, "C:\path\executable.exe") is set to run in 256 color mode, there would be a value named "C:\path\executable.exe" (without the quotes, even if the path contains spaces) under the key [HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers], and the data associated with the value would contain the string "256COLOR". If it is also set to run in compatibility mode under Windows 98/ME, the data would be "WIN98 256COLOR".

所以,方法很简单.在上面提到的密钥下测试是否存在具有可执行文件完整路径的值.如果没有,则尚未指定可执行文件的任何兼容性设置.如果该值存在,则检索其数据并检查数据中是否存在"256COLOR".因此,"WIN95"或"WIN98"或"NT4SP5"或"WIN2000"的存在意味着可执行程序被设置为在该特定操作系统的兼容模式下运行.