如何实时控制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.


Log in to reply
 

走马观花

最近的回复

  • Q

    幾乎沒有看到過,這究竟是什麼原因呢?
    有瞭解的同學可以來說一說。

    read more
  • 这里大概怎么做,然后值怎么传入![替代文字](73c989ff-abab-46e6-99e0-5173a40514b3-image.png 图片地址)例如上图的表格,表头怎么定义,然后表格的内容输入格式

    read more
  • @lsy 我没有在 QtLocation 成功实现高德地图的接入

    可以上 github 搜索用户 vladest,这个用户封装了国外大多数地图,可以参考这个去实现。

    read more
  • 自己顶顶有益健康

    read more

关注我们

微博
QQ群