opencl interop with directx9

IDirect3D9*   d3d   =NULL;

   d3d = Direct3DCreate9(D3D_SDK_VERSION);  

   if (d3d == NULL)  

   {  

      //error handle

   }  

   //set Direct3D presentation parameters  

   D3DPRESENT_PARAMETERS d3dp;   

   ZeroMemory(&d3dp, sizeof(d3dp));  

   d3dp.Windowed = TRUE;  

   d3dp.SwapEffect = D3DSWAPEFFECT_DISCARD;  

   d3dp.BackBufferFormat = D3DFMT_UNKNOWN;  

   //create Direct3D device  

   IDirect3DDevice9*   pDevice   =NULL;

   HRESULT   hr   =d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,  

      D3DCREATE_SOFTWARE_VERTEXPROCESSING,  

      &d3dp, &pDevice );   

   if (pDevice == NULL)  

   {  

      //error handle

   }   

clGetDeviceIDsFromD3D9NV_fn   clGetDeviceIDsFromD3D9NV   =

   (clGetDeviceIDsFromD3D9NV_fn)clGetExtensionFunctionAddress("clGetDeviceIDsFromD3D9NV");

   if (clGetDeviceIDsFromD3D9NV==NULL) 

   {

      //error handle

   }

   cl_uint   uNum(0);

   err   =clGetDeviceIDsFromD3D9NV(gid, CL_D3D9_DEVICE_NV, pDevice, CL_PREFERRED_DEVICES_FOR_D3D9_NV, 1, &g_Device, &uNum);

I use code above, but when I invoke clGetDeviceIDsFromD3D9NV, I got the return value -1. what`s wrong?

thank you.

IDirect3D9*   d3d   =NULL;

   d3d = Direct3DCreate9(D3D_SDK_VERSION);  

   if (d3d == NULL)  

   {  

      //error handle

   }  

   //set Direct3D presentation parameters  

   D3DPRESENT_PARAMETERS d3dp;   

   ZeroMemory(&d3dp, sizeof(d3dp));  

   d3dp.Windowed = TRUE;  

   d3dp.SwapEffect = D3DSWAPEFFECT_DISCARD;  

   d3dp.BackBufferFormat = D3DFMT_UNKNOWN;  

   //create Direct3D device  

   IDirect3DDevice9*   pDevice   =NULL;

   HRESULT   hr   =d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,  

      D3DCREATE_SOFTWARE_VERTEXPROCESSING,  

      &d3dp, &pDevice );   

   if (pDevice == NULL)  

   {  

      //error handle

   }   

clGetDeviceIDsFromD3D9NV_fn   clGetDeviceIDsFromD3D9NV   =

   (clGetDeviceIDsFromD3D9NV_fn)clGetExtensionFunctionAddress("clGetDeviceIDsFromD3D9NV");

   if (clGetDeviceIDsFromD3D9NV==NULL) 

   {

      //error handle

   }

   cl_uint   uNum(0);

   err   =clGetDeviceIDsFromD3D9NV(gid, CL_D3D9_DEVICE_NV, pDevice, CL_PREFERRED_DEVICES_FOR_D3D9_NV, 1, &g_Device, &uNum);

I use code above, but when I invoke clGetDeviceIDsFromD3D9NV, I got the return value -1. what`s wrong?

thank you.