如何实时控制Windows硬件加速的关闭、开启



  • 用代码的方式实时控制Windows硬件加速的关闭、开启,在网上查到通过设置注册表的方式可以实现上述需求,可是要求系统重新启动。如此就达不到实时控制硬件加速的关闭与开启了!在此发帖请教大家有什么好的方法解决这个问题。先解决WinXP下这个需求即可。
    0_1457959558439_WinXP硬件加速开启关闭.png
    如上图是通过手动方式设置关闭Windows硬件加速。需要通过程序实时设置。


  • 网站研运

    @crazyCpp 这个是虚拟机的?
    虚拟机似乎要安装增强组件才行。



  • @jcy WinXP实体系统,我这只是在虚拟机里安装的WinXP。实际需求是在实体WinXP中解决这个问题。


  • 网站研运

    这个看看Win32的API处理吧。



  • 使用Windows API 操作注册表来实现动态改变Windows硬件加速设置,以下是网上找到的解决方法,亲自编写代码测试可用,如有需要Demo者请留言。

    It works as follows:

    • (1) Find out the position of the current video device, information on this may be found in the registry, here:
      \HKLM\HARDWARE\DEVICEMAP\VIDEO\Device\Video0
      There you will find a LPSTR type of entry, pointing to a registry key for the current video device, e.g.
      "\Registry\Machine\System\ControlSet001\Services\G400\Device0"
    • (2) Parse that string, replacing "\Registry\Machine" with HKLM (HKEY_LOCAL_MACHINE) and open the corresponding registry key,
    • (3) Look for a DWORD value "Acceleration.Level". If the value does not exists, hardware acceleration is set to "Full". Otherwise, "Acceleration.Level" may be one of 0x1 to 0x5, 0x5 meaning "No Acceleration", and 0x1 meaning "All but cursor acceleration" (see "Extended Display Settings").
    • (4) Set the desired acceleration level, or delete the entry to set "Full" acceleration mode.
    • (5) Let Windows reload the display settings by using the following code:
        DEVMODE devMode;
        BOOL success = ::EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode);
        if (success == TRUE)
        {
           LONG result = ::ChangeDisplaySettings(&devMode, CDS_RESET);
           printf("ChangeDisplaySettings() returned: %d\n", result);
        }
    

    First, the current display settings are loaded into the devMode variable, and then, the displayed is forced to perform a reset; at this occasion, the "Acceleration.Level" value is read out from the registry and the new acceleration level is set.


 

走马观花

最近的回复

关注我们

微博
QQ群











召唤伊斯特瓦尔