Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 23 of file detect.c.
Referenced by DriverProc().
{ HKEY Key; DWORD KeyIndex = 0; VALIDATE_MMSYS_PARAMETER( ServiceName ); /* Device type zero means "all" */ VALIDATE_MMSYS_PARAMETER( IsValidSoundDeviceType(DeviceType) || DeviceType == 0 ); while ( OpenSoundDeviceRegKey(ServiceName, KeyIndex, &Key) == MMSYSERR_NOERROR ) { HKEY DevicesKey; DWORD ValueType = REG_NONE, ValueIndex = 0; DWORD MaxNameLength = 0, ValueNameLength = 0; PWSTR DevicePath = NULL, ValueName = NULL; DWORD ValueDataLength = sizeof(DWORD); DWORD ValueData; if ( RegOpenKeyEx(Key, REG_DEVICES_KEY_NAME_U, 0, KEY_READ, &DevicesKey) == ERROR_SUCCESS ) { /* Find out how much memory is needed for the key name */ if ( RegQueryInfoKey(DevicesKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &MaxNameLength, NULL, NULL, NULL) != ERROR_SUCCESS ) { SND_ERR(L"Failed to query registry key information\n"); RegCloseKey(DevicesKey); RegCloseKey(Key); return MMSYSERR_ERROR; } DevicePath = AllocateWideString(MaxNameLength + strlen("\\\\.\\")); /* Check that the memory allocation was successful */ if ( ! DevicePath ) { /* There's no point in going further */ RegCloseKey(DevicesKey); RegCloseKey(Key); return MMSYSERR_NOMEM; } /* Insert the device path prefix */ wsprintf(DevicePath, L"\\\\.\\"); /* The offset of the string following this prefix */ ValueName = DevicePath + strlen("\\\\.\\"); /* Copy this so that it may be overwritten - include NULL */ ValueNameLength = MaxNameLength + sizeof(WCHAR); SND_TRACE(L"Interested in devices beginning with %wS\n", DevicePath); while ( RegEnumValue(DevicesKey, ValueIndex, ValueName, &ValueNameLength, NULL, &ValueType, (LPBYTE) &ValueData, &ValueDataLength) == ERROR_SUCCESS ) { /* Device types are stored as DWORDs */ if ( ( ValueType == REG_DWORD ) && ( ValueDataLength == sizeof(DWORD) ) ) { if ( ( DeviceType == 0 ) || ( DeviceType == ValueData ) ) { SND_TRACE(L"Found device: %wS\n", DevicePath); SoundDeviceDetectedProc(ValueData, DevicePath); } } /* Reset variables for the next iteration */ ValueNameLength = MaxNameLength + sizeof(WCHAR); ZeroMemory(ValueName, (MaxNameLength+1)*sizeof(WCHAR)); /*ZeroWideString(ValueName);*/ ValueDataLength = sizeof(DWORD); ValueData = 0; ValueType = REG_NONE; ++ ValueIndex; } FreeMemory(DevicePath); RegCloseKey(DevicesKey); } else { SND_WARN(L"Unable to open the Devices key!\n"); } ++ KeyIndex; RegCloseKey(Key); } return MMSYSERR_NOERROR; }