I am making a call to the CreateDevice function and im having a problem...

Code:
if( FAILED( d3d->CreateDevice(D3DADAPTER_DEFAULT,
                                                 D3DDEVICETYPE_REF, hWnd,
                                            D3DSOFTWARE_VERTEXPROCESSING,
                                                 &d3dpp, &d3ddev) ) )
    return E_FAIL;
When i run the program (which compiles fine) it cause an unhandled exception and the debugger says its in the "&d3dpp, &d3ddev) ) )" line....... what is causing this error???

d3ddev is a valid LPDIRECT3DDEVICE8 and d3dpp is D3DPRESENT_PARAMETERS... d3d is a D3D8 object... whats wrong???