D3DERR_NOTAVAILABLE

Error:
Failed to initialize D3D 9 device (D3DERR_NOTAVAILABLE).
Check if DirectX installed correctly



Solved
You have to reinstall DirectX using this link:
http://www.microsoft.com/download/en/details.aspx?id=8109