views:

109

answers:

1

Hello, I have this little snippet of code with IDirectDraw::GetCaps returning DDERR_INVALIDPARAMS (a.k.a. E_INVALIDARG, a.k.a. 0x80070057).

The loaded dll is ddraw.dll 5.03.2600.5512 (xpsp.080413-0845)

I need to check whether the display hardware has 3D acceleration (DDCAPS_3D).

I have no idea to solve the problem, the snippet is so simple, am I missing something?

Thank you very much.

Alessandro

#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;
}
+2  A: 

As with most DirectX structures, you need to set the size of the DDCAPS structure before passing it on to DirectX.

::ZeroMemory( &hel_caps, sizeof( DDCAPS ) );
::ZeroMemory( &hw_caps, sizeof( DDCAPS ) );
hel_caps.dwSize = sizeof( DDCAPS );
hw_caps.dwSize = sizeof( DDCAPS );
Jeff
Thank you very much!
uvts_cvs