Code:
LPDIRECTDRAW7 lpdd;
DirectDrawCreateEx(NULL,(void**)&lpdd,IID_IDirectDraw7,NULL); 
lpdd->SetCooperativeLevel(hHandle,DDSCL_NORMAL);
if((lpdd->SetDisplayMode(1024,768,16,0,0))!=DD_OK)
	{
	return(0);
	}
//directDraw surface description struct
DDSURFACEDESC2 ddsd;
//directDraw interface pointer
LPDIRECTDRAWSURFACE7 lpddsprimary;
ddsd.dwSize=sizeof(ddsd);
ddsd.dwFlags=DDSD_CAPS;
ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE;
if(lpdd->CreateSurface(&ddsd,&lpddsprimary,NULL)!=DDERR_INVALIDCAPS)
	{
	ShowWindow(hHandle,SW_MINIMIZE);
	}
I've changed out the error flags until I found the one that the CreateSurface function returned. I cannot figure out why this is happening and I have no idea how to fix it. Any help?