问题
I've spent the last two weeks searching everywhere trying to get even so much as a hint on how to do this. This is my first time asking, and trust me when I say that I do not like to ask for help.
But I am at the end of my rope, all I can find is how to list available audio and video devices using someone else's Framework in C#. All I want to do is list the available audio and video devices connected to ones computer from within C# without any additional 3rd party Frameworks.
If any of you could help with this, I would greatly appreciate it. Like I said, I'm at the end of my rope trying to figure out how to do this.
Thanks!
回答1:
After Googling for "C# get video capture devices". I ended up at these two CodeProject articles:
- DirectShow.NET
- DirectX.Capture Class Library
You'll see that there is a lot of COM interop involved. And from the sound of it, I'm not sure you're ready to jump right into that, at it can be a lot of tedious work. I would consider using what is there, and not re-inventing the wheel. After all, they are both in the public domain.
Additionally, there is this post on StackOverflow which has some interesting links:
- Get default audio/video device
回答2:
Try aForge.net http://www.aforgenet.com/ it is fairly simple doing exactly that, or you can use their ready made dialog if it is enough for you.
回答3:
/// <summary>
/// The DirectSoundEnumerate function enumerates the DirectSound Odrivers installed in the system.
/// </summary>
/// <param name="lpDSEnumCallback">callback function</param>
/// <param name="lpContext">User context</param>
[DllImport("dsound.dll", EntryPoint = "DirectSoundEnumerateA", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
static extern void DirectSoundEnumerate(DevicesEnumCallback lpDSEnumCallback, IntPtr lpContext);
/// <summary>
/// The DirectSoundEnumerate function enumerates the DirectSound Input drivers installed in the system.
/// </summary>
/// <param name="lpDSEnumCallback">callback function</param>
/// <param name="lpContext">User context</param>
[DllImport("dsound.dll", EntryPoint = "DirectSoundCaptureEnumerateA", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
static extern void DirectSoundCaptureEnumerate(DevicesEnumCallback lpDSEnumCallback, IntPtr lpContext);
来源:https://stackoverflow.com/questions/11662015/how-do-i-get-list-of-audio-video-and-capture-devices-in-c