[SOLVED] NVAPI_OUT_OF_MEMORY at NvAPI_Stereo_CreateHandleFromIUnknown

Hi all!
[s]I’m trying to get headtracking to work in my Ogre project using the 3d Vision glasses and the NVAPI.

right after getting my renderwindow i execute the following code:[/s]

m_pRenderWnd = m_pRoot->initialise(true, wndTitle);

	//|||||||||||||||||||||||||||||||||||||||||||||||
	NvAPI_Status ret		= NVAPI_OK;
	ret = NvAPI_Initialize();
	if(ret != NVAPI_OK)
	{
		printf("NvAPI_Initialize() failed = 0x%x", ret);
		return false; // Initialization failed
	}
	NvU8 bEnabled = 0;

	NvAPI_Status nvStereo = NvAPI_Stereo_IsEnabled(&bEnabled);

	if (nvStereo!=NVAPI_OK) {

		if (nvStereo==NVAPI_STEREO_NOT_INITIALIZED) OgreFramework::getSingletonPtr()->m_pLog->logMessage("Stereo API not initialized");

		if (nvStereo==NVAPI_API_NOT_INITIALIZED) OgreFramework::getSingletonPtr()->m_pLog->logMessage("nVidia API not initialized");

		if (nvStereo==NVAPI_ERROR) OgreFramework::getSingletonPtr()->m_pLog->logMessage("nVidia API ERROR");

	}
	OgreFramework::getSingletonPtr()->m_pLog->logMessage("nVidia API initialize succeeded");
	
	if (bEnabled) {
		void *d3dDevice = 0;
		m_pRenderWnd->getCustomAttribute("D3DDEVICE", &d3dDevice);
		IDirect3DDevice9* castedDXContext = reinterpret_cast<IDirect3DDevice9*>(d3dDevice );
		

		
		//if(NvAPI_Stereo_CreateHandleFromIUnknown(castedDXContext,han)!=NVAPI_OK)
		if(NvAPI_Stereo_CreateHandleFromIUnknown(Ogre::D3D9RenderSystem::getActiveD3D9Device(),&han)!=NVAPI_OK)		
		{
			OgreFramework::getSingletonPtr()->m_pLog->logMessage("NvAPI_Stereo_CreateHandleFromIUnknown() failed");
			return false; // Initialization failed
		}		
	}

[s]This sadly fails with NVAPI_OUT_OF_MEMORY when i execute NvAPI_Stereo_CreateHandleFromIUnknown.

Does anyone have an idea on how i could fix that, perchance?[/s]

EDIT: Got it figured out. Updated the code.