如何检测系统中是否存在默认录音设备?
如何检测系统是否安装了默认录音设备? 我打赌这可以通过对 Win32 API 的一些调用来完成,有人有这方面的经验吗?
我说的是通过代码来完成此操作,而不是打开控制面板并查看声音选项。
How do I detect if the system has a default recording device installed?
I bet this can be done through some calls to the Win32 API, anyone has any experience with this?
I'm talking about doing this through code, not by opening the control panel and taking a look under sound options.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 DirectX SDK,您可以调用 DirectSoundCaptureEnumerate,这将为系统上的每个 DirectSoundCapture 设备调用 DSEnumCallback 函数。 传递给 DSEnumCallback 的第一个参数是 LPGUID,它是“标识正在枚举的设备的 GUID 的地址,或者对于主设备为 NULL”。
如果您需要做的只是找出是否存在录音设备(如果您确实需要知道默认设备,我认为这还不够好),您可以使用waveInGetNumDevs:
Using the DirectX SDK, you can call DirectSoundCaptureEnumerate, which will call your DSEnumCallback function for each DirectSoundCapture device on the system. The first parameter passed to your DSEnumCallback is an LPGUID, which is the "Address of the GUID that identifies the device being enumerated, or NULL for the primary device".
If all you need to do is find out if a recording device is present (I don't think this is good enough if you really need to know the default device), you can use waveInGetNumDevs:
win32 api 有一个名为 waveInGetNumDevs 的函数它。
The win32 api has a function called waveInGetNumDevs for it.
有一个名为 PortAudio 的开源音频 API,您可以使用它的方法。 我认为该方法称为 Pa_GetDeviceInfo() 或其他名称。
There is an Open Source Audio API called PortAudio that has a method you could use. I think the method is called Pa_GetDeviceInfo() or something.