Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I am developing windows service in VB.net in VS2010

In some case I want to play system default sound for user notification.

I had tried following code to play sound but it's not playing any sound.

VB
System.Media.SystemSounds.Question.Play()


VB
 'I checked by attaching debug that the path is correct
My.Computer.Audio.Play(Path.Combine(My.Application.Info.DirectoryPath, "Blip.wav"), AudioPlayMode.Background)


VB
My.Computer.Audio.PlaySystemSound(Media.SystemSounds.Question)



Even I checked the check box of "Allow to interact with desktop" in service properties after installing service using "InstallUtil"

I checked the speaker connected with my pc.

I have tested it in win xp and win 7

Please help me to resolved this issue and let me know where I am going wrong.

Thanks
Posted

I don't think you can play sounds from a service. At least, I've never heard of a single service ever playing a sound. That was always left up to a user-mode application that talks to the service and receives notifications from it, via named pipes or some other communication method.
 
Share this answer
 
I succeed with this link http://bresleveloper.blogspot.co.il/2012/06/c-service-play-sound-with-naudio.html[^] even if user has not logged in the service will play sound.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900