是程序在兼容模式下运行 [英] Is a Program Running in Compatibility Mode

查看:307
本文介绍了是程序在兼容模式下运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



例如:



程序加载
兼容模式检查
if true then exit
else run

解决方案

从另一个论坛



< blockquote>

经过几次谷歌搜索,在
vain,我决定实验自己。
我发现每个可执行文件的兼容性
设置是
存储 - 正如我想的那样 - 在
Windows注册表中。



存储设置的键


HKEY_CURRENT_USER\软件\Microsoft \Windows
NT \CurrentVersion\AppCompatFlags\Layers

对于指定了
兼容性设置的每个应用程序,
在该键
下存在一个值,它的名称是
可执行文件,数据是由兼容性
设置组成的字符串




指定的字符串中的关键字兼容性设置
是:WIN95 WIN98 NT4SP5

WIN2000 256COLOR 640X480

DISABLETHEMES DISABLECICERO



如果多个设置指定(或
将被指定),数据
由上面的设置
组成,用空格分隔。第一个
四个设置是互斥的,
,即只有一个是指定的
(如果有的话)。我没有
测试指定
多个操作系统的后果。



因此,回到解决您的问题。
要检查可执行文件(假设
C:\path\executable.exe)设置为
,在256色模式下运行,将会有
a名为C:\path\executable.exe的值
(不带引号,即使路径
包含空格)下的键
[HKEY_CURRENT_USER\ Software \ Microsoft \\ \\ Windows
NT \CurrentVersion\AppCompatFlags\Layers],
,与值
相关联的数据将包含字符串256COLOR。
如果它也设置为在Windows
98 / ME下的
兼容模式下运行,数据将是WIN98
256COLOR。



所以,方法很简单。测试
是否有一个值,其中
的完整路径是上面提到的关键字I
下的可执行文件。如果没有,
可执行文件没有指定任何
兼容性设置。如果值
存在,检索其数据并检查

数据中是否存在256COLOR。因此,
WIN95或WIN98或NT4SP5或
WIN2000的存在意味着
可执行文件被设置为以
兼容模式运行特别是
操作系统。



Is there a C++ .NET function that I can call that will detect if my program is running in compatibility mode? If there is not one, could someone show me the code for one? Thanks.

For example:

Program loads up Compatibility Mode check if true then exit else run

解决方案

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

If multiple settings are specified (or are to be specified), the data consists of the settings above separated by a space each. The first four settings are mutually exclusive, i.e. only one of them is to be specified (if at all). I haven't tested the consequences of specifying multiple operating systems.

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".

So, the approach is simple. Test if there is a value with the full path of the executable under the key I mentioned above. If there isn't, the executable has not been specified any compatibility settings. If the value exists, retrieve its data and check for the presence of "256COLOR" in the data. Accordingly, the presence of "WIN95" or "WIN98" or "NT4SP5" or "WIN2000" would mean that the executable is set to run in compatibility mode for that particular operating system.

这篇关于是程序在兼容模式下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆