Click here to Skip to main content
Rate this: bad
good
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
0 OriginalGriff 504
1 Gihan Liyanage 298
2 RyanDev 250
3 Sergey Alexandrovich Kryukov 223
4 Richard Deeming 195
0 Sergey Alexandrovich Kryukov 8,906
1 OriginalGriff 7,771
2 CPallini 2,603
3 Richard MacCutchan 2,121
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 6 Jan 2013
Copyright © CodeProject, 1999-2014
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