using System; using System.Windows.Forms; using System.Runtime.InteropServices; public class Win32 { [DllImport("winmm.dll", CharSet=CharSet.Auto)] public static extern bool sndPlaySound(string lpszSound, int fuSound); } public class HelloWinDotNet { public static void Main() { string windir = Environment.GetEnvironmentVariable("windir") ; string soundfile = windir + "\\MEDIA\\The Microsoft Sound.wav"; DialogResult result = MessageBox.Show("HelloWinDotNet: Play \"The Microsoft Sound.wav\" sound ?? ", "HelloWinDotNet", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result ==DialogResult.OK) Win32.sndPlaySound(soundfile, 0); } }