Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenregistry.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Sound System "MME Buddy" NT4 Library 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: lib/drivers/sound/mment4/registry.c 00005 * 00006 * PURPOSE: Registry operation helper for audio device drivers. 00007 * 00008 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org) 00009 */ 00010 00011 #include "precomp.h" 00012 00013 /* 00014 Open the parameters key of a sound driver. 00015 NT4 only. 00016 */ 00017 MMRESULT 00018 OpenSoundDriverParametersRegKey( 00019 IN LPWSTR ServiceName, 00020 OUT PHKEY KeyHandle) 00021 { 00022 ULONG KeyLength; 00023 PWCHAR ParametersKeyName; 00024 00025 VALIDATE_MMSYS_PARAMETER( ServiceName ); 00026 VALIDATE_MMSYS_PARAMETER( KeyHandle ); 00027 00028 /* Work out how long the string will be */ 00029 KeyLength = wcslen(REG_SERVICES_KEY_NAME_U) + 1 00030 + wcslen(ServiceName) + 1 00031 + wcslen(REG_PARAMETERS_KEY_NAME_U); 00032 00033 /* Allocate memory for the string */ 00034 ParametersKeyName = AllocateWideString(KeyLength); 00035 00036 if ( ! ParametersKeyName ) 00037 return MMSYSERR_NOMEM; 00038 00039 /* Construct the registry path */ 00040 wsprintf(ParametersKeyName, 00041 L"%s\\%s\\%s", 00042 REG_SERVICES_KEY_NAME_U, 00043 ServiceName, 00044 REG_PARAMETERS_KEY_NAME_U); 00045 00046 SND_TRACE(L"Opening reg key: %wS\n", ParametersKeyName); 00047 00048 /* Perform the open */ 00049 if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, 00050 ParametersKeyName, 00051 0, 00052 KEY_READ, 00053 KeyHandle) != ERROR_SUCCESS ) 00054 { 00055 /* Couldn't open the key */ 00056 SND_ERR(L"Failed to open reg key: %wS\n", ParametersKeyName); 00057 FreeMemory(ParametersKeyName); 00058 return MMSYSERR_ERROR; 00059 } 00060 00061 FreeMemory(ParametersKeyName); 00062 00063 return MMSYSERR_NOERROR; 00064 } 00065 00066 /* 00067 Open one of the Device sub-keys belonging to the sound driver. 00068 NT4 only. 00069 */ 00070 MMRESULT 00071 OpenSoundDeviceRegKey( 00072 IN LPWSTR ServiceName, 00073 IN DWORD DeviceIndex, 00074 OUT PHKEY KeyHandle) 00075 { 00076 DWORD PathLength; 00077 PWCHAR RegPath; 00078 00079 VALIDATE_MMSYS_PARAMETER( ServiceName ); 00080 VALIDATE_MMSYS_PARAMETER( KeyHandle ); 00081 00082 /* 00083 Work out the space required to hold the path: 00084 00085 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ 00086 sndblst\ 00087 Parameters\ 00088 Device123\ 00089 */ 00090 PathLength = wcslen(REG_SERVICES_KEY_NAME_U) + 1 00091 + wcslen(ServiceName) + 1 00092 + wcslen(REG_PARAMETERS_KEY_NAME_U) + 1 00093 + wcslen(REG_DEVICE_KEY_NAME_U) 00094 + GetDigitCount(DeviceIndex); 00095 00096 /* Allocate storage for the string */ 00097 RegPath = AllocateWideString(PathLength); 00098 00099 if ( ! RegPath ) 00100 { 00101 return MMSYSERR_NOMEM; 00102 } 00103 00104 /* Write the path */ 00105 wsprintf(RegPath, 00106 L"%ls\\%ls\\%ls\\%ls%d", 00107 REG_SERVICES_KEY_NAME_U, 00108 ServiceName, 00109 REG_PARAMETERS_KEY_NAME_U, 00110 REG_DEVICE_KEY_NAME_U, 00111 DeviceIndex); 00112 00113 SND_TRACE(L"Opening reg key: %wS\n", RegPath); 00114 00115 /* Perform the open */ 00116 if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE, 00117 RegPath, 00118 0, 00119 KEY_READ, 00120 KeyHandle) != ERROR_SUCCESS ) 00121 { 00122 /* Couldn't open the key */ 00123 SND_ERR(L"Failed to open reg key: %wS\n", RegPath); 00124 FreeMemory(RegPath); 00125 return MMSYSERR_ERROR; 00126 } 00127 00128 FreeMemory(RegPath); 00129 00130 return MMSYSERR_NOERROR; 00131 } Generated on Fri May 25 2012 04:15:25 for ReactOS by
1.7.6.1
|