1.在WindowsXP平台VC中键入:
_asm
{
  push ax
  in al,61h
  pop ax
}
运行时报错,为什么?2.VC有没有使用PC喇叭发声的函数?

解决方案 »

  1.   

    2.VC有没有使用PC喇叭发声的函数?
    The 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,      // sound frequency
      DWORD dwDuration   // sound duration
    );
      

  2.   

    NT系列系统下可以直接调用API,Beep()
    98下:
    Freq是频率
     __asm
     {
            push bx
            in al,0x61
            mov bl, aL
            and aL, 3
            jne Skip
            mov aL, bL
            or aL, 3
            out 0x61, aL
            mov aL, 0xB6
            out 0x43, aL
      Skip: mov ax, Freq
            out 0x42, aL
            mov aL, ah
            out 0x42, aL
            pop bx
     }停止用
     __asm
     {
            in al,0x61;
            and al,0xFC;
            out 0x61,al;
     }