A sample program to find the default audio device.

This is a discussion on A sample program to find the default audio device. within the C++ Programming forums, part of the General Programming Boards category; Can somebody please provide a very simple program to find the default audio device on the machine? I have tried ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    100

    A sample program to find the default audio device.

    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!

  2. #2
    Registered User deoren's Avatar
    Join Date
    Mar 2003
    Posts
    63
    I'm far too new to C++ to provide any help, but I'd suggest posting snippets of the error messages to provide additional details.
    It is better to fail with honor than win by deceit
    - unknown

    My erratic tinkerings:
    http://projects.whyaskwhy.org/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ubuntu 9.02 Cannot find network device
    By C_ntua in forum Tech Board
    Replies: 12
    Last Post: 09-10-2009, 10:34 PM
  2. set system's default audio device
    By geek@02 in forum Windows Programming
    Replies: 1
    Last Post: 11-26-2007, 07:23 AM
  3. REQ: Change Audio Input Device?
    By DeepBlackMagic in forum Windows Programming
    Replies: 0
    Last Post: 09-01-2006, 02:24 PM
  4. How Can I Find the Default Browser?
    By DeepFyre in forum Windows Programming
    Replies: 2
    Last Post: 02-12-2005, 07:55 PM
  5. How can I find the default software on a computer?
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 08-16-2002, 12:55 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21