computer-lzy

C# Beep

public class myBeep
    {
        [DllImport(
"kernal32.dll")]
        
public static extern bool Beep(int freq, int duration);

        
public enum MessageBeepType
        {
            Default 
= -1,
            Ok 
= 0x00000000,
            Error 
= 0x00000010,
            Question 
= 0x00000020,
            Warning 
= 0x00000030,
            Information 
= 0x00000040
        }

        [DllImport(
"user32.dll", SetLastError = true)]
        
public static extern bool MessageBeep(MessageBeepType type);

        
public void BeepShow()
        {
            
for (int i = 0; i < 10; i++)
            {
                System.Threading.Thread.Sleep(
500);
                Console.Beep(
4000800);// Beep(800,300);
            }
        }

        
public void MessageBeepShow()
        {
            
for (int i = 0; i < 10; i++)
            {
                System.Threading.Thread.Sleep(
500);
                MessageBeep(MessageBeepType.Question);
            }
        }


    }

备注:console.Beep(4000800)其中4000是指发声的频率,800是发声时间!

分类:

技术点:

相关文章:

  • 2021-09-25
  • 2022-01-21
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2021-09-25
  • 2021-09-25
猜你喜欢
  • 2021-11-07
  • 2021-09-25
  • 2022-12-23
  • 2021-12-06
  • 2021-07-24
  • 2021-11-23
相关资源
相似解决方案