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 1: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 390
1 Jochen Arndt 165
2 Richard MacCutchan 135
3 DamithSL 95
4 Garth J Lancaster 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web01 | 2.8.141220.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