D3DCAPS9 caps; d3dDevice->GetDeviceCaps( &caps ); if( caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL ) { }
Be *very* careful with this though. Even cards which conditionally support non power of two texture sizes do not do so under all circumstances and it will always be a LOT slower than using a power of two texture.