一个驱逐蚊子的计划?

时间:2010-01-30 17:46:18

标签: c#

不,我很认真。

最近,我读到当PC的压电蜂鸣器以一定的频率振动时,声音会击退蚊子。

这是真的吗?

如何以C#编程方式访问PC蜂鸣器(而不是扬声器)?

我不知道蚊子,但我的头疼得像疯了似的。啊...!

2 个答案:

答案 0 :(得分:16)

using System.Runtime.InteropServices;

[DllImport("KERNEL32.DLL",
EntryPoint="Beep",SetLastError=true,CharSet=CharSet.Unicode,
ExactSpelling=true,CallingConvention=CallingConvention.StdCall)]

public static extern bool Beep(int pitch , int duration);

Beep(500,1000); 

答案 1 :(得分:2)

似乎可以通过对本机Windows代码的非托管调用来执行此操作,如http://www.geekpedia.com/code118_Beep-In-The-PC-Speaker.html中所述。