| View previous topic :: View next topic |
| Author |
Message |
wezel Freshman
Joined: 09 Oct 2003 Posts: 30
|
Posted: Oct 10th, 2003 01:05 PM Post subject: sndSoundPlay |
|
|
Hi,
I've got an API function in my app but it's not working...
Here's the code:
Private Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (ByVal strFile As String, lngPlayFile As Long) As Long
'To play sound:
sndPlaySound App.Path & "sound.wav", 1
I've used this API function before but i'm not sure if i wrote it this way...
Does anyone knows how to make this API function work ?
Thanx at advance
Wesley _________________ Real Programmers don't comment their code - it's hard to write, it should be hard to read |
|
| Back to top |
|
wezel Freshman
Joined: 09 Oct 2003 Posts: 30
|
Posted: Oct 10th, 2003 01:38 PM Post subject: |
|
|
oops, forfor a Byval there in the API Declaration... Works now
/me slaps wezel _________________ Real Programmers don't comment their code - it's hard to write, it should be hard to read |
|
| Back to top |
|
Avis Junior Poster

Joined: 07 Oct 2003 Posts: 510 Location: India
|
Posted: Oct 11th, 2003 01:43 AM Post subject: |
|
|
| For a better description and example check this [api]sndPlaySound[/api] |
|
| Back to top |
|
wezel Freshman
Joined: 09 Oct 2003 Posts: 30
|
Posted: Oct 12th, 2003 05:56 PM Post subject: |
|
|
Thanx Avis.
But the thing is... I don't like using code I don't understand myself. And I don't understand these parts of the code:
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
sndPlaySound CDBox.filename, SND_ASYNC Or SND_NODEFAULT
What does the value that the sonstants get mean ?
Why do you have to use constants ?
Thanx
Wesley _________________ Real Programmers don't comment their code - it's hard to write, it should be hard to read |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Oct 13th, 2003 07:01 AM Post subject: |
|
|
Well constants are used to describe a value, a number so it can be easier to read and recognize. For example, isn't easier to read this :
| Code: | | sndPlaySound CDBox.filename, SND_ASYNC Or SND_NODEFAULT |
than this?
| Code: | | sndPlaySound CDBox.filename, &H1 Or &H2 |
Even though both are correct... _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
wezel Freshman
Joined: 09 Oct 2003 Posts: 30
|
Posted: Oct 13th, 2003 07:12 AM Post subject: |
|
|
Yeah, that's true, but why do they get that value ?
And why do the the names of the constants have to be words like SND_ASYNC ?
I know I have a lot of questions, but, if you'd be so kind to explain me this I would be very gratefull, I've been asking myself this question for quite some time now
Thanx!
Wesley _________________ Real Programmers don't comment their code - it's hard to write, it should be hard to read |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Oct 13th, 2003 11:55 AM Post subject: |
|
|
Well the name is something like that so that it can be generally recognized. You can name a constant anything you like! You can change SND_ASYNC to Wezel and put Wezel in your code instead of SND_ASYNC and it'll work. A constant is just something that has a value and can't change. Of course, if everyone renamed the constants to anything that they wanted no one else would understand the code
They get that value for no particular reason! It is just that the API when it was designed it knew how to recognize some numbers and do things accordingly. So whoever made the API also made a list with the capabilities of the API (and the numbers that it reads) and can do something afterwards. So I guess the constant names come from the creator of the API (that uses them) creator...
HTH,
Philip _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
wezel Freshman
Joined: 09 Oct 2003 Posts: 30
|
Posted: Oct 13th, 2003 12:00 PM Post subject: |
|
|
Thanx!
Now I can use more API's I wanted to use before but didn't understand!
Thanx!
Wesley _________________ Real Programmers don't comment their code - it's hard to write, it should be hard to read |
|
| Back to top |
|
P.T.A.M. Administrator

Joined: 08 Oct 2003 Posts: 752 Location: Greece
|
Posted: Oct 13th, 2003 12:28 PM Post subject: |
|
|
No problem
Also it might be a good idea to download the API-Guide and the API Viewer  _________________ No one is completely useless. They can at least be an example of what to avoid. |
|
| Back to top |
|
|