title: Play wave file from a Windows Service (C#)
body: <p>I need to play a wav file from a C# application running as a Windows Service. I have tried both System.Media.SoundPlayer and a P/Invoke call to WinMM.dll (which is probably what SoundPlayer is doing). </p>
  
  <pre><code>[DllImport("WinMM.dll")]
  private static extern bool PlaySound(string fname, int Mod, int flag); 
  </code></pre>
  
  <p>If I run my code as a console application, the sounds play. When I run it from a service, no luck, and I guess I'm not surprised.</p>
  
  <p>So is there a way to play a sound from a windows service? Would something like DirectSound help? Or am I going to be stuck writing a console application and having the windows service app communicate with it as an intermediary?</p>
  
  <p>Thanks in advance</p>