Can somebody please provide a very simple program to find the default audio device on the machine? I have tried researching this issue elsewhere, and I would find leads (such as GetDefaultAudioEndpoint()), but I have yet to find a single example of how to apply this to my own code. Every time I look at something elsewhere online, I run into linker errors and all kinds of stuff that is too cryptic for somebody who's completely new to programming something like this to really work with. One program I came up with, but which failed, is as follows:
Code:
//#include <windows.h>
//#include <tchar.h>
#include <atlstr.h>
#include <mmdeviceapi.h>
//#include <devicetopology.h>
//#include <functiondiscoverykeys.h>
#include <iostream>
//using namespace std;
int main()
{
HRESULT hr;
CComPtr<IMMDeviceEnumerator> pMMDeviceEnumerator;
pMMDeviceEnumerator->GetDefaultAudioEndpoint(eCapture, eMultimedia, 0);
//cout << hr;
return 0;
}
That generates a run-time error having to do with atlbase.h.
If somebody could please show me a few changes I could make to that program OR a completely different, yet really simple program to find the default audio device, it would be appreciated. I'm really walking into unfamiliar territory with trying to implement this sort of functionality or getting into this sort of API, so please explain anything that's not trivial. Thanks!