Windows Enumerate Audio Devices

I'm trying to get some information from audio devices however whenever I run my code below, the device description and manufacturer are wrong. What am I doing wrong?

#include <stdio.h>
#include <SetupAPI.h>
#include <devpkey.h>

DWORD STDAPICALLTYPE EnumAudioDevices() {

HANDLE hEnumerator = NULL;
DWORD dwIndex = 0;
WCHAR szBuffer[256] = { 0 };
DEVPROPTYPE propType = 0;
SP_DEVINFO_DATA spDeviceInfo = { sizeof(SP_DEVINFO_DATA) };

hEnumerator = SetupDiGetClassDevs(NULL, L"SWD\\MMDEVAPI", NULL, DIGCF_ALLCLASSES);

while (SetupDiEnumDeviceInfo(hEnumerator, dwIndex++, &spDeviceInfo)) {

// Name
SetupDiGetDeviceProperty(hEnumerator, &spDeviceInfo, &DEVPKEY_Device_FriendlyName, &propType, (PBYTE)szBuffer, 512, NULL, 0);
wprintf(L"\nDevice %i: %s\n", dwIndex, szBuffer);
memset(szBuffer, 0, 512);

// ID
SetupDiGetDeviceInstanceId(hEnumerator, &spDeviceInfo, szBuffer, 512, NULL);
wprintf(L"ID: %s\n", szBuffer);
memset(szBuffer, 0, 512);

// Description
SetupDiGetDeviceProperty(hEnumerator, &spDeviceInfo, &DEVPKEY_Device_DeviceDesc, &propType, (PBYTE)szBuffer, 512, NULL, 0);
wprintf(L"Description: %s\n", szBuffer);
memset(szBuffer, 0, 512);

// Manufacturer
SetupDiGetDeviceProperty(hEnumerator, &spDeviceInfo, &DEVPKEY_Device_Manufacturer, &propType, (PBYTE)szBuffer, 512, NULL, 0);
wprintf(L"Manufacturer: %s\n", szBuffer);
memset(szBuffer, 0, 512);

}

return dwIndex;
}

int __cdecl main() {

wprintf(L"\nDevice Count: %i\n\n", EnumAudioDevices());

return 0;
}
Topic archived. No new replies allowed.