for (long i=50;i <= 2000 ;i+=20)太短了加大就可以了!

解决方案 »

  1.   

    using System;
    using System.Runtime.InteropServices;
    class test
    {
    [DllImport("kernel32.dll")]
    private static extern int Beep(int dwFreq ,int dwDuration) ; public static void Main()
    {
    int a=0X7FF;
    int b=1000;
    Beep(a,b);
              }
    }
    using System;
    using System.Runtime.InteropServices;
    class test
    {
    [DllImport("kernel32.dll")]
    private static extern int Beep(int dwFreq ,int dwDuration) ; public static void Main()
    {
    int a=0X7FF;
    int b=1000;
    Beep(a,b);
              }
    }
    叫出来下我一大跳,什么鬼调
      

  2.   

    c#里面是这样调用的吧?
    [DllImport("kernel32.dll", EntryPoint="Beep")]
    public static extern long beep(ref long dwFreq, ref long dwDuration);
      

  3.   

    哦,明白了b是发音时间,调短点就好多了,免得吓出心脏病
    BeepThe Beep function generates simple tones on the speaker. The function is synchronous; it does not return control to its caller until the sound finishes.
    BOOL Beep(
      DWORD dwFreq,
      DWORD dwDuration
    );Parameters
    dwFreq 
    [in] Frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF). 
    Windows 95/98/Me: The Beep function ignores this parameter.dwDuration 
    [in] Duration of the sound, in milliseconds. 
    Windows 95/98/Me: The Beep function ignores this parameter.Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res
      

  4.   

    [DllImport("kernel32.dll")]
    private static extern int Beep(int dwFreq ,int dwDuration) ;
    private void buttonTest_Click(object sender, System.EventArgs e)
    {
    int j=10;
    for (int i=50;i <= 2000 ;i+=20)  Beep(i,j);
    }跟时间长短没有关系,按照breezem(夜空幽灵)这样写就好了~~~