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)
20 Open the parameters key of a sound driver.
24 OpenSoundDriverParametersRegKey(
25 IN LPWSTR ServiceName
,
29 PWCHAR ParametersKeyName
;
31 VALIDATE_MMSYS_PARAMETER( ServiceName
);
32 VALIDATE_MMSYS_PARAMETER( KeyHandle
);
34 /* Work out how long the string will be */
35 KeyLength
= wcslen(REG_SERVICES_KEY_NAME_U
) + 1
36 + wcslen(ServiceName
) + 1
37 + wcslen(REG_PARAMETERS_KEY_NAME_U
);
39 /* Allocate memory for the string */
40 ParametersKeyName
= AllocateWideString(KeyLength
);
42 if ( ! ParametersKeyName
)
43 return MMSYSERR_NOMEM
;
45 /* Construct the registry path */
46 wsprintf(ParametersKeyName
,
48 REG_SERVICES_KEY_NAME_U
,
50 REG_PARAMETERS_KEY_NAME_U
);
52 SND_TRACE(L
"Opening reg key: %wS\n", ParametersKeyName
);
54 /* Perform the open */
55 if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
59 KeyHandle
) != ERROR_SUCCESS
)
61 /* Couldn't open the key */
62 SND_ERR(L
"Failed to open reg key: %wS\n", ParametersKeyName
);
63 FreeMemory(ParametersKeyName
);
64 return MMSYSERR_ERROR
;
67 FreeMemory(ParametersKeyName
);
69 return MMSYSERR_NOERROR
;
73 Open one of the Device sub-keys belonging to the sound driver.
77 OpenSoundDeviceRegKey(
78 IN LPWSTR ServiceName
,
85 VALIDATE_MMSYS_PARAMETER( ServiceName
);
86 VALIDATE_MMSYS_PARAMETER( KeyHandle
);
89 Work out the space required to hold the path:
91 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
96 PathLength
= wcslen(REG_SERVICES_KEY_NAME_U
) + 1
97 + wcslen(ServiceName
) + 1
98 + wcslen(REG_PARAMETERS_KEY_NAME_U
) + 1
99 + wcslen(REG_DEVICE_KEY_NAME_U
)
100 + GetDigitCount(DeviceIndex
);
102 /* Allocate storage for the string */
103 RegPath
= AllocateWideString(PathLength
);
107 return MMSYSERR_NOMEM
;
112 L
"%ls\\%ls\\%ls\\%ls%d",
113 REG_SERVICES_KEY_NAME_U
,
115 REG_PARAMETERS_KEY_NAME_U
,
116 REG_DEVICE_KEY_NAME_U
,
119 SND_TRACE(L
"Opening reg key: %wS\n", RegPath
);
121 /* Perform the open */
122 if ( RegOpenKeyEx(HKEY_LOCAL_MACHINE
,
126 KeyHandle
) != ERROR_SUCCESS
)
128 /* Couldn't open the key */
129 SND_ERR(L
"Failed to open reg key: %wS\n", RegPath
);
131 return MMSYSERR_ERROR
;
136 return MMSYSERR_NOERROR
;