Play wave file from a Windows Service (C#)
问题 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). [DllImport("WinMM.dll")] private static extern bool PlaySound(string fname, int Mod, int flag); 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. So is there a way to play a sound from a windows service? Would