Reputation: 4750
This needs to be able to work for the last two or three Windows versions (7, Vista, and probably XP). In Visual Basic .NET, how can I find the default audio device (I'm looking for speakers and stuff, not mics). Thanks!
EDIT: Guys, I am really walking into unfamiliar territory here. It seems like every time I try to use a code sample, there are build errors that could not be more cryptic and involve the errors occurring inside of libraries and all sorts of stuff like that. Is there anything for a total beginner to learn how to do this? Thanks!
Upvotes: 0
Views: 3191
Reputation: 26
Some audio APIs (winMM, DirectSound, DirectShow, Media Foundation, WASAPI) allow you to enumerate devices, but offer a default; some (Beep, PlaySound) only allow playing via the default device.
The simplest API to start with is PlaySound (well, except perhaps Beep, but that is of limited usefulness.) What are you trying to play? That will help determine the choice of the API to use.
Upvotes: 0
Reputation: 69724
There are a few audio APIs in Windows, and all of them offer device enumeration. The recent "main" API is Vista+ only, so you need to decide if XP support is important.
Vista+ enumeration: Enumerating Audio Devices
Code good for all Windows versions: Sample: how to enumerate waveIn and waveOut devices on your system
Those are C++ code links above, in VB.NET you will need P/Invoke calls or a wrapper library, such as NAudio
to take care of inner details.
Upvotes: 2