The problem seems to be mixing DX8 and DX9 files. The first DirectX include is a DX8 file, the second is DX9. Pick one or the other and stick to it; either use DirectX 8 or DirectX 9 but you can't mix and match.
You might be able to get it to work simply by changing the first include to:
as DirectX 9 should still supply all the interfaces for DX8.
And no, it's not finding those classes. Those errors are actually telling you that "CD3DEnumeration", "CD3DSettings", "D3DCAPS9", and ""LPDIRECT3D9" are not declared anywhere. Which is obvious; those are DirectX 9 classes but you included the DirectX 8 header (D3DX8.h) not the DirectX 9 header (D3DX9.h).