There is a interesting function which can play a System sound.spa
First let's see the WinAPI.rest
//聲明: 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.code
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!blog