
Resource files containing WAV files
Thanks for the help.
It took me a while to figure out how to add a wav file to the project, but I
got it done. After trying so many ways, not sure I can remember how, but it
is there, and I got the Build action figured out as well. I had the Import
statements in a Module1, but figured out that I have to have them in the
individual form where this code resides, not quite sure I understand that...
I had a problem with the : --- Dim bytes(len) As Byte --- statement.
Error message on Compile "Constant expression required" .
Just to try to get it to work, I looked up the size of the wav file,
subtracted 1 and used that number as a constant. It compiled fine, but
still does not play when it is called.
Any thoughts? Perhaps I will sleep on it and see if it looks easier
tommorrow. Suspect I am one small step away.
Thanks a lot for your assistance. It has been years since I have coded
anything, much has changed...
Ross
Quote:
> Add a wav file to you app and set Build Action to Embedded Resource then
use
> this code:
> Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA"
(ByRef
> adr As Byte, ByVal hModule As Int32, ByVal dwFlags As Int32) As Int32
> Dim str As Stream =
System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("
Y
Quote:
> ourAppName.filename.wav")
> Dim len As Int32 = CInt(str.Length - 1)
> Dim bytes(len) As Byte
> str.Read(bytes, 0, len)
> PlaySound(bytes(0), 0, 4)
> HTH
> --
> Corrado Cavalli [Microsoft MVP]
> UGIdotNET - http://www.ugidotnet.org