Win32:如何确定 DirectDraw 是否启用?

发布于 2024-09-03 17:17:35 字数 1280 浏览 9 评论 0原文

使用 CachedBitmapsGDIPlus 中,如果 Windows 视频“硬件加速”降低太多,则会出现图形损坏 - 例如禁用 DirectDraw

在此处输入图像描述

有六级硬件加速:

  • 禁用所有加速
  • 禁用除基本加速之外的所有加速。 (服务器 计算机上的默认设置)
  • 禁用所有 DirectDraw 和 Direct3D 加速,以及所有光标和高级绘图加速
  • 禁用所有光标和高级绘图加速
  • 禁用光标和位图加速
  • 所有加速均已启用( 上的默认设置台式机)

如果禁用 DirectDraw,则在 GDI+ 中使用 DrawCachedBitmap 将导致图形损坏。对我来说使用较慢的 DrawImage 很容易() API(如果未启用 DirectDraw) - 但我必须能够检测 DirectDraw 已禁用。

如何以编程方式检查 DirectDraw 是否已启用?


问题是: dxdiag 如何执行此操作:

alt text

另请参阅

KB191660 - DirectDraw 或 Direct3D 选项不可用 (存档)

When using CachedBitmaps in GDIPlus, there is graphical corruption if Windows video "Hardware Acceleration" is lowered too much - such that DirectDraw is disabled:

enter image description here

There are six levels of hardware acceleration:

  • Disable all accelerations
  • Disable all but basic accelerations. (Default on server machines)
  • Disable all DirectDraw and Direct3D accelerations, as well as all cursor and advanced accelerations
  • Disable all cursor and advanced drawing accelerations
  • Disable cursor and bitmap accelerations
  • All accelerations are enabled (Default on desktop machines)

If DirectDraw is disabled, then using DrawCachedBitmap in GDI+ will result in graphical corruption. It's easy enough for me to use the slower DrawImage() API if DirectDraw is not enabled - but i have to be able to detect that DirectDraw is disabled.

How can i programatically check if DirectDraw is enabled?


The question is: How does dxdiag do this:

alt text

See also

KB191660 - DirectDraw or Direct3D option is unavailable (archive)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

看海 2024-09-10 17:17:35

如果您下载最新的 DirectX SDK (我确信旧的 sdk 有类似的示例)有一个查询 DXDIAG 信息的示例。

该示例位于 (SDK Root)\Samples\C++\Misc\DxDiagReport

在 dxdiaginfo.cpp 中值得注意的方法

CDxDiagInfo::CDxDiagInfo
CDxDiagInfo::Init
CDxDiagInfo::QueryDxDiagViaDll    
CDxDiagInfo::GetDisplayInfo

如果运行该程序,它会输出一个巨大的值列表。我认为您感兴趣的值是 pDisplayInfo->m_szDDStatusEnglish

If you download the latest DirectX SDK (I'm sure older sdk's have similar examples) there is an example of querying DXDIAG info.

The example is located at (SDK Root)\Samples\C++\Misc\DxDiagReport

In dxdiaginfo.cpp methods of note

CDxDiagInfo::CDxDiagInfo
CDxDiagInfo::Init
CDxDiagInfo::QueryDxDiagViaDll    
CDxDiagInfo::GetDisplayInfo

If you run the program it ouputs a giant list of values. I think the value you're interested in is pDisplayInfo->m_szDDStatusEnglish

丶情人眼里出诗心の 2024-09-10 17:17:35

您可以检查注册表中的加速度滑块值。

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{'some hex string'}\0000\Acceleration.Level

您可能需要循环浏览 Video 中的所有文件夹,因为通常有多个条目。

Acceleration.Level 值

  • 5 禁用所有加速
  • 4 禁用除基本加速之外的所有加速。 (服务器计算机上的默认设置)
  • 3 禁用所有 DirectDraw 和 Direct3D 加速,以及所有光标和高级加速
  • 2 禁用所有光标和高级绘图加速
  • 1 禁用光标和位图加速
  • 0 所有加速均已启用(台式机上的默认设置)

更新:

这是一个有关以编程方式更改/检查加速级别的旧线程。
http://www.autoitscript.com/forum/topic/61185-hardware-加速度/

You could check the registry for the acceleration slider value.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Video\{'some hex string'}\0000\Acceleration.Level

You're probably going to have to loop through all the folders in Video as there are generally more than one entry.

Acceleration.Level Values

  • 5 Disable all accelerations
  • 4 Disable all but basic accelerations. (Default on server machines)
  • 3 Disable all DirectDraw and Direct3D accelerations, as well as all cursor and advanced accelerations
  • 2 Disable all cursor and advanced drawing accelerations
  • 1 Disable cursor and bitmap accelerations
  • 0 All accelerations are enabled (Default on desktop machines)

Update:

Here's an older thread about programatically changing/checking the acceleration level.
http://www.autoitscript.com/forum/topic/61185-hardware-acceleration/

勿挽旧人 2024-09-10 17:17:35

您可以查询 IDirectDraw 接口,看看有什么确实如此。我认为如果硬件加速关闭,它将失败,但您可能想测试 GetCaps() 或 TestCooperativeLevel()。

LPDIRECTDRAW lpdd7 = NULL; // DirectDraw 7.0

// first initialize COM, this will load the COM libraries
// if they aren't already loaded
if (FAILED(CoInitialize(NULL)))
   {
   // error
   } // end if

// Create the DirectDraw object by using the
// CoCreateInstance() function
if (FAILED(CoCreateInstance(&CLSID_DirectDraw,
                         NULL, CLSCTX_ALL,
                         &IID_IDirectDraw7,
                         &lpdd7)))
   {
   // error
   }


// now before using the DirectDraw object, it must
// be initialized using the initialize method

if (FAILED(IDirectDraw7_Initialize(lpdd7, NULL)))
{
    // error
}

lpdd7->Release();
lpdd7 = NULL; // set to NULL for safety

// now that we're done with COM, uninitialize it
CoUninitialize();

不幸的是,DirectDraw 文档不再包含在 SDK 中。您可能需要旧版本才能获取示例和头文件。

You could query a IDirectDraw interface and see what it does. I assume it will fail if hardware acceleration is turned off, but you might want to test GetCaps() or TestCooperativeLevel().

LPDIRECTDRAW lpdd7 = NULL; // DirectDraw 7.0

// first initialize COM, this will load the COM libraries
// if they aren't already loaded
if (FAILED(CoInitialize(NULL)))
   {
   // error
   } // end if

// Create the DirectDraw object by using the
// CoCreateInstance() function
if (FAILED(CoCreateInstance(&CLSID_DirectDraw,
                         NULL, CLSCTX_ALL,
                         &IID_IDirectDraw7,
                         &lpdd7)))
   {
   // error
   }


// now before using the DirectDraw object, it must
// be initialized using the initialize method

if (FAILED(IDirectDraw7_Initialize(lpdd7, NULL)))
{
    // error
}

lpdd7->Release();
lpdd7 = NULL; // set to NULL for safety

// now that we're done with COM, uninitialize it
CoUninitialize();

Unfortunately the DirectDraw docs are no longer included in the SDKs. You might need an older version to get the samples and header files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文