Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

API and LoadResData function?

Posted on 2003-11-18
2
Medium Priority
?
485 Views
Last Modified: 2013-12-25
hi
we paste my code,below,please elaborate
when clicking command button ,sound wont play.why?



Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Private x() As Byte
 Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
SendKeys "%+"
SendKeys "%+"
Text1.Visible = True
Text1.SetFocus
x = LoadResData(101, "AA")
 ing = sndPlaySound(x(0), SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
 Text1.Text = ing
End Sub

Private Sub Form_Click()
End
End Sub

Private Sub Timer1_Timer()
a = Int(Rnd * 255)
b = Int(Rnd * 255)
c = Int(Rnd * 255)
Label1.ForeColor = RGB(a, b, c)
Form1.BackColor = RGB(c, a, b)
Label1.FontSize = Int(Rnd * 60) + 10
End Sub


thanks
0
Comment
Question by:asdf246
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 300 total points
ID: 9772386
The sndPlaySound API expects to be passed a string telling it what file to play, not a byte array.

You could read your res file, write that data to a temp file, and then play the temp file.

    Dim data() As Byte
    data = LoadResData(101, "AA") ' or use
    Open "Temp.wav" For Binary Access Write As #1
    Put #1, , data
    Close #1
    sndPlaySound "Temp.wav", SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY

Just delete the file when you are done with it.  I'm sure if there is a way to directly play a file stored in a byte array in memory.

Idle_Mind
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9773601
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question