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 {参数是个常数; 根据不同的常数发出不同...

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              = 0;
MB_ICONHAND        = 16;
MB_ICONQUESTION    = 32;
MB_ICONEXCLAMATION = 48;
MB_ICONASTERISK    = 64;


//举例, 下面代码会发出错误警告
begin
  MessageBeep(16);
end;


//另外 Delphi 的 Beep 方法在 SysUtils 单元是这样实现的:
procedure Beep;
begin
  MessageBeep(0);
end;

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

 1 #include <Windows.h>
 2 
 3 int _tmain(int argc, _TCHAR* argv[])
 4 {
 5     for( UINT i = 0; i < 100; i ++) {
 6         MessageBeep(i);
 7         Sleep(1000);
 8     }
 9     return 0;
10 }

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

目录
相关文章
Busy Dialog init - hashchange will call BusyDialog.open - flower
Created by Wang, Jerry, last modified on Jun 29, 2015
92 0
Busy Dialog init - hashchange will call BusyDialog.open - flower
SM66 does not have debug button in Q system
SM66 does not have debug button in Q system
SM66 does not have debug button in Q system
|
Android开发
Android TextureView &amp; MediaPlayer implements video media player
Android TextureView & MediaPlayer implements video media player code: import android.
1144 0
|
Java 数据库连接 数据库