Results 1 to 3 of 3

Thread: Play WAV file who's data is strored in an EXE's resources

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2008
    Posts
    1,238

    Play WAV file who's data is strored in an EXE's resources

    I've stored a WAV file in the resources of my program using VB6 resource editor. When compiled this data will be stored in the resources section of the EXE file. Now I know the API call Playsound is capable of playing WAV files. But my WAV file is now ACTUALLY IN the EXE file itself (complete WAV file header sound data etc, is all stored in the EXE file as binary resource data and can be seen if the EXE is opened in a hex editor). How do I play a WAV resource stored in the EXE file? Is there an API call for that? Please help.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Play WAV file who's data is strored in an EXE's resources

    You can extract and play it.
    Code:
    Public Sub ExtractFile(ByVal sPath As String)
        Dim bytData() As Byte
        ReDim bytData(Len(LoadResData(101, "CUSTOM")))
        bytData = LoadResData(101, "CUSTOM")
        Open sPath For Binary Access Write As #1
        Put #1, , bytData
        Close #1
    End Sub
    Sample usage:
    Code:
    ExtractFile "C:\test.wav"
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Play WAV file who's data is strored in an EXE's resources

    You can also play WAV from an array and do not need to write it to file. Search for APIs PlaySound & sndPlaySound for examples.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width