且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

C#编程中的Jack Sensing

更新时间:1970-01-01 07:59:18

好吧,这取决于插孔的敏感程度.说真的,你到底在说什么?要控制外部实际设备,您需要一个界面.然后,您对该接口进行编码.您不能只要求神奇地控制硬件的C#代码.

您是指USB设备吗?您可以判断它是否存在,但是不存在和拔出插头有何不同?

^ ]是程序员的方式处理这样的问题.
Well, that depends on how sensitive jack is. Seriously, what the hell are you talking about ? To control an external real world device, you need an interface. Then you code to that interface. you can''t just ask for C# code that magically controls a piece of hardware.

Do you mean a USB device ? You can tell if it''s present or not, but how is not present and unplugged different ?

This[^] is how programmers deal with issues like this.


我找到了.
使用 CoreAudioApi 并从 MMDeviceEnumerator 类创建对象.我们可以使用 MMDeviceEnumerator 方法检查音频端口状态.
I found it.
Use CoreAudioApi and create object from MMDeviceEnumerator class. We can use MMDeviceEnumerator methods for checking audio port status.