DWORD dwFreq;
DWORD dwDuration;
BOOL bQuit;DWORD WINAPI BeepThread(void *pTime)
{
     DWORD dwTime=(DWORD)pTime;
     while(!bQuit)
     {
           LONG lQuit;
           Beep(dwFreq,dwDuration);
           Sleep(dwTime);
     }
     return (DWORD)bQuit;
}void YourCodeComeHere()
{
      DWORD dwThread;
      HANDLE hThread;
      bQuit=FALSE;
      dwFreq=...;
      dwDuration=...;
      hThread=CreateThread(NULL,0,BeepThread,(LPVOID)10000,NULL,&dwThread);
      if(hThread==NULL)exit(-1);
      CloseHandle(hThread);
      ...//now do whatever you want.
      bQuit=TRUE;//notify beep thread to quit
      ...
}

解决方案 »

  1.   

    OnInitUpdate()//用ClassWizard选WM_INITUPDATE消息,建其处理函数
    {
       SetTimer(1,10000,NULL);//1为第一号定时器,10000 毫秒 = 10 秒
    }OnTimer(UINT nIDEvent)
    {   
       MessageBeep(-1);//同上,建WM_TIMER处理函数
     }DestroyWindow()//同上,重载DestroyWindow
    {
       KillTimer(1);//关闭该定时器
    }一定要会用ClassWizard的哦。   
      

  2.   

    是呀,這麼簡單的問題用OnTimer就可以搞定了
      

  3.   

    也可不用定时器啊。
    1。开一个线程
    HWND hWnd=GetSafeHwnd();
    AfxBeginThread(Beep,THREAD_PRIORITY_NORMAL);2.线程函数(要作为全局函数。。)
    UINT Beep(LPVOID param)
    {
    MessageBeep(-1);
    Sleep(10000);//sleep 10秒
    }
      

  4.   

    CreateWaitableTimer
    加上waitforsingleobject即可!