2 * PROJECT: ReactOS Sound System "MME Buddy" NT4 Library
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: lib/drivers/sound/mment4/registry.c
6 * PURPOSE: Registry operation helper for audio device drivers.
8 * PROGRAMMERS: Andrew Greenwood (silverblade@reactos.org)
13 #include <mmebuddy_debug.h>
16 Open the parameters key of a sound driver.
20 OpenSoundDriverParametersRegKey(
21 IN LPWSTR ServiceName
,
25 PWCHAR ParametersKeyName
;
27 VALIDATE_MMSYS_PARAMETER( ServiceName
);
28 VALIDATE_MMSYS_PARAMETER( KeyHandle
);
30 /* Work out how long the string will be */
31 KeyLength
= wcslen(REG_SERVICES_KEY_NAME_U
) + 1
32 + wcslen(ServiceName
) + 1
33 + wcslen(REG_PARAMETERS_KEY_NAME_U
);
35 /* Allocate memory for the string */
36 ParametersKeyName
= AllocateWideString(KeyLength
);
38 if ( ! ParametersKeyName
)
39 return MMSYSERR_NOMEM
;
41 /* Construct the registry path */
42 wsprintf(ParametersKeyName
,
44 REG_SERVICES_KEY_NAME_U
,
46 REG_PARAMETERS_KEY_NAME_U
);
48 SND_TRACE(L
"Opening reg key: %wS\n", ParametersKeyName
);
50 /* Perform the open */
51 if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
55 KeyHandle
) != ERROR_SUCCESS
)
57 /* Couldn't open the key */
58 SND_ERR(L
"Failed to open reg key: %wS\n", ParametersKeyName
);
59 FreeMemory(ParametersKeyName
);
60 return MMSYSERR_ERROR
;
63 FreeMemory(ParametersKeyName
);
65 return MMSYSERR_NOERROR
;
69 Open one of the Device sub-keys belonging to the sound driver.
73 OpenSoundDeviceRegKey(
74 IN LPWSTR ServiceName
,
81 VALIDATE_MMSYS_PARAMETER( ServiceName
);
82 VALIDATE_MMSYS_PARAMETER( KeyHandle
);
85 Work out the space required to hold the path:
87 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
92 PathLength
= wcslen(REG_SERVICES_KEY_NAME_U
) + 1
93 + wcslen(ServiceName
) + 1
94 + wcslen(REG_PARAMETERS_KEY_NAME_U
) + 1
95 + wcslen(REG_DEVICE_KEY_NAME_U
)
96 + GetDigitCount(DeviceIndex
);
98 /* Allocate storage for the string */
99 RegPath
= AllocateWideString(PathLength
);
103 return MMSYSERR_NOMEM
;
108 L
"%ls\\%ls\\%ls\\%ls%d",
109 REG_SERVICES_KEY_NAME_U
,
111 REG_PARAMETERS_KEY_NAME_U
,
112 REG_DEVICE_KEY_NAME_U
,
115 SND_TRACE(L
"Opening reg key: %wS\n", RegPath
);
117 /* Perform the open */
118 if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
122 KeyHandle
) != ERROR_SUCCESS
)
124 /* Couldn't open the key */
125 SND_ERR(L
"Failed to open reg key: %wS\n", RegPath
);
127 return MMSYSERR_ERROR
;
132 return MMSYSERR_NOERROR
;