   why doesn't this code work?
BOOL InitDD(HWND hwnd){if(FAILED(DirectDrawCreateEx(NULL,(void**)&lpDD,IID_IDirectDraw7,NULL)))return FALSE;if(FAILED(lpDD->SetCooperativeLevel(hwnd,DDSCL_NORMAL)))return FALSE;DDSURFACEDESC2 ddsd;ZeroMemory(&ddsd,sizeof(ddsd));ddsd.dwSize = sizeof(ddsd);ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT;ddsd.dwBackBufferCount = 1;ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|  DDSCAPS_COMPLEX|  DDSCAPS_FLIP;if(FAILED(lpDD->CreateSurface(&ddsd, &lpPrimary, NULL)))return FALSE;ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;if(FAILED(lpPrimary->GetAttachedSurface(&ddsd.ddsCaps,&lpBack)))return FALSE;return TRUE;}It fails to create the primary surface why!? It''s a windowed application by the way I guess that''s the problem since this code does work if I make it run fullscreen...Do I need anything else in particular for it to work as a window? I tried looking online in teh google for some sample code but no luck.Thanks. 
  IIRC you can''t use a DirectDraw back buffer in windowed applications. ;  Yes, for windowed mode you use a regular offscreen surface instead of a back buffer then blt it to the front buffer 