I am currently making a frogger game for an assignment at college. I decided to put some background music into the game and used the following code:
Public Class SoundClass
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal Name _
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
' name specifies the sound file when the SND_FILENAME flag is set.
' hmod specifies an executable file handle.
' hmod must be Nothing if the SND_RESOURCE flag is not set.
' flags specifies which flags are set.
' The PlaySound documentation lists all valid flags.
Public Const SND_SYNC = &H0 ' play synchronously
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_FILENAME = &H20000 ' name is file name
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom
Public Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_SYNC)
End Sub
End Class
in the form_load procedure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim SoundInst As New SoundClass()
SoundInst.PlaySoundFile("\frogger.wav")
End Sub
The only problem is that when I go to run the code I get the following error:
An unhandled exception of type 'System.Security.SecurityException' occurred in Frogger.exe
Additional information: System.Security.Permissions.SecurityPermission
Hope I haven't been too confusing, I have tried looking on google but can't seem to find anything to help.
Thanks in advance for any help. Dan

Using playsound to play background music
NinJA999
arooni
I have read up on the caspol.exe and I understand what it's for. The problem is I don't know what to do or what code to write. I am guessing the problem is that i'm on the college network and it ain't liking the code. Could you please give me some help with the code I need to put in my program.
Thank you Dan
aliasx
SonAsylum
Perhaps if you embed the wav file it MIGHT
work better.
Also, with VB Express you do not need to use APIs
to do this.
See my post at http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=953440&SiteID=1