Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
4.8 KiB

  1. /****************************************************************************
  2. *
  3. * File: sndinfo7.cpp
  4. * Project: DxDiag (DirectX Diagnostic Tool)
  5. * Author: Mike Anderson (manders@microsoft.com)
  6. * Purpose: Gather DX7-specific sound information
  7. *
  8. * (C) Copyright 1998 Microsoft Corp. All rights reserved.
  9. *
  10. ****************************************************************************/
  11. #define DIRECTSOUND_VERSION 0x0700 // <-- note difference from sndinfo.cpp
  12. #include <tchar.h>
  13. #include <Windows.h>
  14. #include <mmsystem.h>
  15. #include <dsound.h>
  16. #include "dsprv.h"
  17. static HRESULT PrvGetDeviceDescription7
  18. (
  19. LPKSPROPERTYSET pKsPropertySet,
  20. REFGUID guidDeviceId,
  21. PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA *ppData
  22. );
  23. static HRESULT PrvReleaseDeviceDescription7
  24. (
  25. PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA pData
  26. );
  27. /****************************************************************************
  28. *
  29. * GetRegKey
  30. *
  31. ****************************************************************************/
  32. HRESULT GetRegKey(LPKSPROPERTYSET pKSPS7, REFGUID guidDeviceID, TCHAR* pszRegKey)
  33. {
  34. HRESULT hr;
  35. PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA pdsddd;
  36. TCHAR szInterface[200];
  37. TCHAR* pchSrc;
  38. TCHAR* pchDest;
  39. if (FAILED(hr = PrvGetDeviceDescription7(pKSPS7, guidDeviceID, &pdsddd)))
  40. return hr;
  41. if (pdsddd->Interface == NULL) // This seems to always be the case on Win9x
  42. {
  43. lstrcpy(pszRegKey, TEXT(""));
  44. PrvReleaseDeviceDescription7( pdsddd );
  45. return E_FAIL;
  46. }
  47. lstrcpy(szInterface, pdsddd->Interface);
  48. PrvReleaseDeviceDescription7( pdsddd );
  49. pdsddd = NULL;
  50. pchSrc = szInterface + 4; // skip "\\?\"
  51. pchDest = pszRegKey;
  52. while (TRUE)
  53. {
  54. *pchDest = *pchSrc;
  55. if (*pchDest == TEXT('#')) // Convert "#" to "\"
  56. *pchDest = TEXT('\\');
  57. if (*pchDest == TEXT('{')) // End if "{" found
  58. *pchDest = TEXT('\0');
  59. if (*pchDest == TEXT('\0'))
  60. break;
  61. pchDest++;
  62. pchSrc++;
  63. }
  64. if (*(pchDest-1) == TEXT('\\')) // Remove final "\"
  65. *(pchDest-1) = TEXT('\0');
  66. return S_OK;
  67. }
  68. // The following function is identical to the one defined in dsprvobj.cpp,
  69. // except it is defined with DIRECTSOUND_VERSION at 0x0700, so you get more
  70. // description data (namely the Interface string).
  71. /***************************************************************************
  72. *
  73. * PrvGetDeviceDescription7
  74. *
  75. * Description:
  76. * Gets the extended description for a given DirectSound device.
  77. *
  78. * Arguments:
  79. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  80. * DirectSoundPrivate object.
  81. * REFGUID [in]: DirectSound device id.
  82. * PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA [out]: receives
  83. * description.
  84. *
  85. * Returns:
  86. * HRESULT: DirectSound/COM result code.
  87. *
  88. ***************************************************************************/
  89. static HRESULT PrvGetDeviceDescription7
  90. (
  91. LPKSPROPERTYSET pKsPropertySet,
  92. REFGUID guidDeviceId,
  93. PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA *ppData
  94. )
  95. {
  96. PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA pData = NULL;
  97. ULONG cbData;
  98. DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA Basic;
  99. HRESULT hr;
  100. Basic.DeviceId = guidDeviceId;
  101. hr =
  102. pKsPropertySet->Get
  103. (
  104. DSPROPSETID_DirectSoundDevice,
  105. DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
  106. NULL,
  107. 0,
  108. &Basic,
  109. sizeof(Basic),
  110. &cbData
  111. );
  112. if(SUCCEEDED(hr))
  113. {
  114. pData = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA)new BYTE [cbData];
  115. if(!pData)
  116. {
  117. hr = DSERR_OUTOFMEMORY;
  118. }
  119. }
  120. if(SUCCEEDED(hr))
  121. {
  122. ZeroMemory(pData, cbData);
  123. pData->DeviceId = guidDeviceId;
  124. hr =
  125. pKsPropertySet->Get
  126. (
  127. DSPROPSETID_DirectSoundDevice,
  128. DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
  129. NULL,
  130. 0,
  131. pData,
  132. cbData,
  133. NULL
  134. );
  135. }
  136. if(SUCCEEDED(hr))
  137. {
  138. *ppData = pData;
  139. }
  140. else if(pData)
  141. {
  142. delete pData;
  143. }
  144. return hr;
  145. }
  146. /***************************************************************************
  147. *
  148. * PrvReleaseDeviceDescription7
  149. *
  150. ***************************************************************************/
  151. HRESULT PrvReleaseDeviceDescription7( PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA pData )
  152. {
  153. delete[] pData;
  154. return S_OK;
  155. }