头文件:mmsystem.h

函数原型:BOOL WINAPI PlaySound(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound)

参考http://zhidao.baidu.com/question/41366091.html

#include <windows.h>
#include <mmsystem.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
 int choice = MessageBox(NULL, TEXT("重启计算机?"), TEXT("重启"), MB_OKCANCEL | MB_ICONQUESTION | MB_DEFBUTTON2);
 if(choice == IDOK)
 {
  PlaySound("C:WINDOWSMediaWindows XP 关机.wav", NULL, SND_FILENAME | SND_ASYNC);
  MessageBox(NULL, TEXT("关闭计算机……"), TEXT("关闭"), MB_OK);
  PlaySound(NULL, NULL, SND_FILENAME);
  choice = MessageBox(NULL, TEXT("启动计算机?"), TEXT("启动"), MB_YESNO | MB_ICONQUESTION);
  if(choice == IDYES)
  {
   PlaySound("C:WINDOWSMediaWindows XP 启动.wav", NULL, SND_FILENAME | SND_SYNC);
   MessageBox(NULL, TEXT("计算机已成功启动!"), TEXT("启动成功"), MB_OK);
  }
 }
 return 0;
}

重启计算机