How to beep using PC speaker?

后端 未结 3 1900
挽巷
挽巷 2021-01-02 13:06

I want to make a beep sound using PC speaker in C#. When using the following code:

[DllImport(\"kernel32.dll\", EntryPoint = \"Beep\", SetLastError = true,
E         


        
3条回答
  •  孤城傲影
    2021-01-02 13:39

    From Windows 7 onwards, you can no longer easily make sound via the internal speaker.

    For Windows 7, we resolved the issue completely – we moved all the functionality that used to be contained in Beep.Sys into the user mode system sounds agent – now when you call the Beep() API instead of manipulating the 8254 chip the call is re-routed into a user mode agent which actually plays the sounds.

    […]

    There were also some unexpected consequences. The biggest was that people started noticing when applications called Beep(). They had placed their PCs far enough away (or there was enough ambient noise) that they had never noticed when their PC was beeping at them until the sounds started coming out their speakers.

    See here for details:

    https://docs.microsoft.com/en-us/archive/blogs/larryosterman/whats-up-with-the-beep-driver-in-windows-7

提交回复
热议问题