You can use StretchRect to copy the depth buffer. To get cpu access you'll need to use a D3DFMT_D32F_LOCKABLE or D3DFMT_D16F_LOCKABLE. However, not all cards support these formats. You can also write a shader that outputs depth and render your scene to a render target and use that shader.
Then you can lock the surface and get the data from the locked rectangle.