一个驱逐蚊子的计划?

Viv*_*ard 27 c#

不,我认真的.

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

真的吗?

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

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

ran*_*ght 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); 
Run Code Online (Sandbox Code Playgroud)

  • 我的狗刚刚开始嚎叫,我只读了代码.必须工作. (29认同)
  • 值得一提的是,Beep驱动程序在Win7中经历了一些可能影响使用它的变化:http://blogs.msdn.com/larryosterman/archive/2010/01/04/what-s-up-with- the-beep-driver-in-windows-7.aspx :) (4认同)