//+------------------------------------------------------------------------- // // Microsoft Windows // // Copyright (C) Microsoft Corporation, 1998 - 1999 // // File: dsenumobj.cpp // //-------------------------------------------------------------------------- #define DIRECTSOUND_VERSION 0x600 #define OLDDSENUM 1 #include "stdafx.h" #include "Direct.h" #include "dms.h" #include "dxglob7obj.h" #include "DSEnumObj.h" extern BSTR GUIDtoBSTR(LPGUID pGuid); extern "C" BOOL PASCAL objDirectSoundEnumCallback( #ifdef OLDDSENUM LPGUID lpGuid, #else LPCGUID lpGuid, #endif LPCSTR lpDriverDescription, LPCSTR lpDriverName, LPVOID lpArg ) { GUID guid; ZeroMemory(&guid,sizeof(GUID)); if (lpGuid){ memcpy(&guid,lpGuid,sizeof(GUID)); } DPF(1,"Entered objDirectDrawEnumCallback \r\n"); C_dxj_DSEnumObject *pObj=(C_dxj_DSEnumObject*)lpArg; if (pObj==NULL) return TRUE; if (pObj->m_nCount >= pObj->m_nMax) { pObj->m_nMax += 10; if (pObj->m_pList) { void* tmp = realloc(pObj->m_pList,sizeof(DxDriverInfo)* pObj->m_nMax); if (tmp) pObj->m_pList=(DxDriverInfo*)tmp; else return FALSE; } else pObj->m_pList=(DxDriverInfo*)malloc(sizeof(DxDriverInfo)* pObj->m_nMax); if (pObj->m_pList==NULL) { pObj->m_bProblem=TRUE; return FALSE; } } USES_CONVERSION; ZeroMemory(&(pObj->m_pList[pObj->m_nCount]),sizeof(DxDriverInfo)); pObj->m_pList[pObj->m_nCount].strGuid=GUIDtoBSTR((GUID*)&guid); // pObj->m_pList[pObj->m_nCount].strGuid=GUIDtoBSTR((GUID*)lpGuid); if (lpDriverDescription!=NULL) { pObj->m_pList[pObj->m_nCount].strDescription=T2BSTR(lpDriverDescription); } if (lpDriverName!=NULL){ pObj->m_pList[pObj->m_nCount].strName=T2BSTR(lpDriverName); } pObj->m_nCount++; return TRUE; } C_dxj_DSEnumObject::C_dxj_DSEnumObject() { m_nMax=0; m_pList=NULL; m_nCount=0; m_bProblem=FALSE; } C_dxj_DSEnumObject::~C_dxj_DSEnumObject() { //empty list if (m_pList){ for (int i=0;i; if (!pNew) return E_OUTOFMEMORY; pNew->m_bProblem=FALSE; if (pcbFunc) { hr=pcbFunc(objDirectSoundEnumCallback,pNew); } else if (pcbFunc2) { hr=pcbFunc2(objDirectSoundEnumCallback,pNew); } else { hr = E_INVALIDARG; } if (pNew->m_bProblem) hr=E_OUTOFMEMORY; if FAILED(hr) { //let destructor do the clean up delete pNew; return hr; } hr=pNew->QueryInterface(IID_I_dxj_DSEnum,(void**)ppRet); return hr; } HRESULT C_dxj_DSEnumObject::getName( long index, BSTR *ret) { if (m_pList==NULL) return E_FAIL; if (index < 1) return E_INVALIDARG; if (index > m_nCount) return E_INVALIDARG; *ret=SysAllocString(m_pList[index-1].strName); return S_OK; } HRESULT C_dxj_DSEnumObject::getDescription( long index, BSTR *ret) { if (m_pList==NULL) return E_FAIL; if (index < 1) return E_INVALIDARG; if (index > m_nCount) return E_INVALIDARG; *ret=SysAllocString(m_pList[index-1].strDescription); return S_OK; } HRESULT C_dxj_DSEnumObject::getGuid( long index, BSTR *ret) { if (m_pList==NULL) return E_FAIL; if (index < 1) return E_INVALIDARG; if (index > m_nCount) return E_INVALIDARG; *ret=SysAllocString(m_pList[index-1].strGuid); return S_OK; } HRESULT C_dxj_DSEnumObject::getCount(long *retVal) { *retVal=m_nCount; return S_OK; }