複製鏈接
請複製以下鏈接發送給好友

MessageBeep

鎖定
MessageBeep函數用來播放一個波形聲音。
This function plays a waveform sound. (該函數是播放一段系統音樂)
中文名
MessageBeep
性    質
播放一個波形聲音
返回值
Return Values
零表示不成功
Zero indicates failure

目錄

MessageBeep定義

MessageBeep函數用來播放一個波形聲音。
This function plays a waveform sound. (該函數是播放一段系統音樂)
BOOL MessageBeep(UINT uType //根據不同的類型來定);
Parameters(參數)
uType
Specifies the sound type, as identified by an entry in the [sounds] section of the registry. It is one of the following values.
Value Description (數值描述):
0xFFFFFFFF SystemDefault (從機器的揚聲器中發出蜂鳴聲)
MB_ICONASTERISK SystemAsterisk (播放由SystemAsterisk定義的聲音)
MB_ICONEXCLAMATION SystemExclamation (播放由SystemExclamation定義的聲音)
MB_ICONHAND SystemHand (播放由SystemHand定義的聲音)
MB_ICONQUESTION SystemQuestion (播放由SystemQuestion定義的聲音)
MB_OK SystemDefault (播放由SystemDefault定義的聲音)
Return Values(返回值):
1.Nonzero indicates success. (非零表示成功)
2.Zero indicates failure. (零表示不成功)
3.To get extended error information, call GetLastError.(通過GetLastError函數來獲取錯誤信息)
Remarks(説明):
After queuing the sound, the MessageBeep function returns control to the calling function and plays the sound asynchronously.
If it cannot play the specified alert sound, MessageBeep attempts to play the system default sound. If it cannot play the system default sound, the function produces a standard beep sound through the computer speaker.
The user can disable the warning beep by using the Sound Control Panel application.
Requirements
OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Msgbeep.lib.
See Also
MessageBox

MessageBeep程序示例

#include<windows.h>
int main(int argc,char*argv[])
{
    Sleep(1000);
    ::MessageBeep(0xFFFFFFFF);//API函數前加“::”符號,表示這是一個全局的函數,以與c++類的成員函數相區分
    Sleep(1000);
    ::MessageBeep(MB_ICONASTERISK);
    Sleep(1000);
    ::MessageBeep(MB_ICONEXCLAMATION);
    Sleep(1000);
    ::MessageBeep(MB_ICONHAND);
    Sleep(1000);
    ::MessageBeep(MB_ICONQUESTION);
    Sleep(1000);
    ::MessageBeep(MB_OK);
    Sleep(1000);
    return 0;
}