Directx 什么可能导致IDirectDraw::GetCaps返回DDERR_INVALIDPARAMS?

Directx 什么可能导致IDirectDraw::GetCaps返回DDERR_INVALIDPARAMS?,directx,directdraw,Directx,Directdraw,我有一段IDirectDraw::GetCaps返回的代码DDERR\u INVALIDPARAMS(又称E\u INVALIDARG,又称0x80070057) 加载的dll是ddraw.dll 5.03.2600.5512(xpsp.080413-0845) 我需要检查显示硬件是否有3D加速(DDCAPS_3D) 我不知道如何解决这个问题,代码片段很简单,我是否遗漏了什么 多谢各位 亚历山德罗 #include <ddraw.h> #include <iostream>

我有一段IDirectDraw::GetCaps返回的代码
DDERR\u INVALIDPARAMS
(又称E\u 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;
}
#包括
#包括

#定义TEST_HR(HR)如果(HR!=DD_OK){std::cout与大多数DirectX结构一样,您需要在将DDCAPS结构传递给DirectX之前设置其大小

::ZeroMemory( &hel_caps, sizeof( DDCAPS ) );
::ZeroMemory( &hw_caps, sizeof( DDCAPS ) );
hel_caps.dwSize = sizeof( DDCAPS );
hw_caps.dwSize = sizeof( DDCAPS );

与大多数DirectX结构一样,在将DDCAPS结构传递给DirectX之前,需要设置其大小

::ZeroMemory( &hel_caps, sizeof( DDCAPS ) );
::ZeroMemory( &hw_caps, sizeof( DDCAPS ) );
hel_caps.dwSize = sizeof( DDCAPS );
hw_caps.dwSize = sizeof( DDCAPS );