Win32: How to determine if DirectDraw is enabled?
When using CachedBitmaps
in GDIPlus , there is graphical corruption if Windows video "Hardware Acceleration" is lowered too much - such that DirectDraw is disabled:
alt text http://i48.tinypic.com/10qeaeb.jpg
There are six levels of hardware acceleration:
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:
See also
KB191660 - DirectDraw or Direct3D option is unavailable
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)SamplesC++MiscDxDiagReport
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
You could check the registry for the acceleration slider value.
HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlVideo{'some hex string'} 000Acceleration.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
Update:
Here's an older thread about programatically changing/checking the acceleration level. http://www.autoitscript.com/forum/topic/61185-hardware-acceleration/
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.
链接地址: http://www.djcxy.com/p/50342.html上一篇: 什么是最快的GDI +渲染设置?