Click here to Skip to main content
12,448,720 members (54,283 online)
Rate this:
 
Please Sign up or sign in to 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.

System.Media.SystemSounds.Question.Play()

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

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 5-Jan-13 0:53am
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160811.3 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100