Results 1 to 2 of 2

Thread: Using VB resources with API

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    1

    Post

    I'm actually wondering on how I could make sounds fit into the exe file of VB progs : I thought I could use the resource system, but I have now another problem: How could I access this resources with api , like PlaySound, or MsgboxIndirect(for the Icon), knowing the Res ID (101.. in my case) ? I tried using the SND_RESOURCE with PlaySound, but it doesn't play my sound , but only the default sound !

    If someone could help me...


    TestMan57, France

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Location
    quebec
    Posts
    81

    Cool

    I would suggest that you store the sound file in your
    resource then use the LoadResData function to load it into
    a byte array.

    Once you have it in memory, save the byte array's contents
    to a disk file and then play it using either a mediaplayer
    control or directly through the MCI API - specifying the disk file to use.

    to save a byte array to disk:
    Code:
    ' ---------------------------------------------------------------------------
    ' Write byte array to file
    ' ---------------------------------------------------------------------------
      Dim intFile    As Integer
      Dim bytData()  As Byte
      Dim strFile As String
    
      strFile = "filename.wav" ' for example
    
      intFile = FreeFile
      Open strFile For Binary Access Write As #intFile
      Put #intFile, , bytData()
      Close #intFile
    This also works on avi's and other less 'standard'
    resources (i.e. not icon, bmp, menu, etc.)

    If someone has a better way I too am interested.

    have fun
    C/C++,Delphi,VB6,Java,PB (blech!),ASP,JSP,SQL...bla bla bla and bla
    I love deadlines. I like the whooshing sound they make as they fly by.
    —Douglas Adams

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