Leaked source code of windows server 2003
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.

191 lines
5.2 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. if( lstrlen(szInterface) > 5 &&
  51. lstrlen(szInterface) < 200 )
  52. {
  53. pchSrc = szInterface + 4; // skip "\\?\"
  54. pchDest = pszRegKey;
  55. while (TRUE)
  56. {
  57. *pchDest = *pchSrc;
  58. if (*pchDest == TEXT('#')) // Convert "#" to "\"
  59. *pchDest = TEXT('\\');
  60. if (*pchDest == TEXT('{')) // End if "{" found
  61. *pchDest = TEXT('\0');
  62. if (*pchDest == TEXT('\0'))
  63. break;
  64. pchDest++;
  65. pchSrc++;
  66. }
  67. if( lstrlen(pszRegKey) > 1 )
  68. {
  69. if (*(pchDest-1) == TEXT('\\')) // Remove final "\"
  70. *(pchDest-1) = TEXT('\0');
  71. }
  72. }
  73. return S_OK;
  74. }
  75. // The following function is identical to the one defined in dsprvobj.cpp,
  76. // except it is defined with DIRECTSOUND_VERSION at 0x0700, so you get more
  77. // description data (namely the Interface string).
  78. /***************************************************************************
  79. *
  80. * PrvGetDeviceDescription7
  81. *
  82. * Description:
  83. * Gets the extended description for a given DirectSound device.
  84. *
  85. * Arguments:
  86. * LPKSPROPERTYSET [in]: IKsPropertySet interface to the
  87. * DirectSoundPrivate object.
  88. * REFGUID [in]: DirectSound device id.
  89. * PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA [out]: receives
  90. * description.
  91. *
  92. * Returns:
  93. * HRESULT: DirectSound/COM result code.
  94. *
  95. ***************************************************************************/
  96. static HRESULT PrvGetDeviceDescription7
  97. (
  98. LPKSPROPERTYSET pKsPropertySet,
  99. REFGUID guidDeviceId,
  100. PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA *ppData
  101. )
  102. {
  103. PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA pData = NULL;
  104. ULONG cbData;
  105. DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA Basic;
  106. HRESULT hr;
  107. Basic.DeviceId = guidDeviceId;
  108. hr =
  109. pKsPropertySet->Get
  110. (
  111. DSPROPSETID_DirectSoundDevice,
  112. DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
  113. NULL,
  114. 0,
  115. &Basic,
  116. sizeof(Basic),
  117. &cbData
  118. );
  119. if(SUCCEEDED(hr))
  120. {
  121. pData = (PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA)new BYTE [cbData];
  122. if(!pData)
  123. {
  124. hr = DSERR_OUTOFMEMORY;
  125. }
  126. }
  127. if(SUCCEEDED(hr))
  128. {
  129. ZeroMemory(pData, cbData);
  130. pData->DeviceId = guidDeviceId;
  131. hr =
  132. pKsPropertySet->Get
  133. (
  134. DSPROPSETID_DirectSoundDevice,
  135. DSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION,
  136. NULL,
  137. 0,
  138. pData,
  139. cbData,
  140. NULL
  141. );
  142. }
  143. if(SUCCEEDED(hr))
  144. {
  145. *ppData = pData;
  146. }
  147. else if(pData)
  148. {
  149. delete[] pData;
  150. }
  151. return hr;
  152. }
  153. /***************************************************************************
  154. *
  155. * PrvReleaseDeviceDescription7
  156. *
  157. ***************************************************************************/
  158. HRESULT PrvReleaseDeviceDescription7( PDSPROPERTY_DIRECTSOUNDDEVICE_DESCRIPTION_DATA pData )
  159. {
  160. delete[] pData;
  161. return S_OK;
  162. }