1

我有这个带有 IDirectDraw::GetCaps 返回的小代码片段DDERR_INVALIDPARAMS(又名E_INVALIDARG,又名 0x80070057)。

加载的dll是ddraw.dll 5.03.2600.5512 (xpsp.080413-0845)

我需要检查显示硬件是否有 3D 加速(DDCAPS_3D)。

我不知道如何解决这个问题,代码片段是如此简单,我错过了什么吗?

非常感谢你。

亚历山德罗

#include <ddraw.h>
#include <iostream>

#define TEST_HR(hr) if(hr!=DD_OK){ std::cout << "Error 0x" << std::hex << static_cast<unsigned long>(hr) << " at line: " << std::dec << __LINE__; return __LINE__;}

int main(int argc, char* argv[])
{
   ::CoInitialize( 0 );
   IDirectDraw* dd;
   TEST_HR( ::DirectDrawCreate( 0, &dd, 0 ) );
   DDCAPS hel_caps, hw_caps;
   ::ZeroMemory( &hel_caps, sizeof( DDCAPS ) );
   ::ZeroMemory( &hw_caps, sizeof( DDCAPS ) );
   TEST_HR( dd->GetCaps( &hw_caps, &hel_caps ) );
   ::CoUninitialize();
   return 0;
}
4

1 回答 1

4

与大多数 DirectX 结构一样,您需要先设置 DDCAPS 结构的大小,然后再将其传递给 DirectX。

::ZeroMemory( &hel_caps, sizeof( DDCAPS ) );
::ZeroMemory( &hw_caps, sizeof( DDCAPS ) );
hel_caps.dwSize = sizeof( DDCAPS );
hw_caps.dwSize = sizeof( DDCAPS );
于 2009-12-09T17:02:51.330 回答