MessageBeep - Play a System sound

There is a interesting function which can play a System sound.

First let's see the WinAPI.

//声明:
MessageBeep(
uType: UINT {参数是个常数; 根据不同的常数发出不同的声音, 也就是调用了不同的 wav}
): BOOL; //参数 uType 可选值:
MB_OK = ;
MB_ICONHAND = ;
MB_ICONQUESTION = ;
MB_ICONEXCLAMATION = ;
MB_ICONASTERISK = ; //举例, 下面代码会发出错误警告
begin
MessageBeep();
end; //另外 Delphi 的 Beep 方法在 SysUtils 单元是这样实现的:
procedure Beep;
begin
MessageBeep();
end;

If you wana beep in your console program. You can use it like following.

 #include <Windows.h>

 int _tmain(int argc, _TCHAR* argv[])
{
for( UINT i = ; i < ; i ++) {
MessageBeep(i);
Sleep();
}
return ;
}

Well, Running it, it will beep differently in every second. Thank you!

上一篇:DUMP3 企业级电商项目


下一篇:使用 cloc 统计代码行数