BOOL BeepAsm( DWORD dwFreq, // sound frequency, in hertz DWORD dwDuration) // sound duration, in milliseconds { BOOL bRet; __asm { //1 汇编调用Kernel32.dll Beep函数 MOV EAX, dwDuration; PUSH EAX; //Duration of the sound, in milliseconds. MOV EAX, dwFreq PUSH EAX; //Frequency of the sound, in hertz. MOV EAX, 0X7C837AA7; //kernel32 + beep CALL EAX //EAX 保存返回值 MOV bRet, EAX } return bRet; } BOOL BeepEx( DWORD dwFreq, // sound frequency, in hertz DWORD dwDuration) // sound duration, in milliseconds { BOOL bRet = 0; HMODULE hKernel32 = GetModuleHandle(_T("kernel32.dll")); if(hKernel32) { BOOL (WINAPI* BeepFun)(DWORD,DWORD) = (BOOL (WINAPI *)(DWORD,DWORD))GetProcAddress(hKernel32, "Beep"); if(BeepFun) { bRet = BeepFun(dwFreq, dwDuration); } } return bRet; }