I have played around with windows api for quite a while and can show you how to call windows api commands in visual basic. I can make this into a tutorial if anyone is interested.
Go to this site and download the API guide:
http://allapi.mentalis.org/agnet/apiguide.shtml
This will give you a good list to use of windows api commands.
The functions are in VB and VB.Net, so you need to know how to convert them.
Here's a basic beep function:
Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
This is in VB code.
To make this in Dark Basic Profession code you have to know what parts you are using.
The part that says:
This is the dll or lib that you can find the function.
To load the dll just use:
load dll "kernel32.dll",1
The next part is calling the function:
Where it says:
"Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long)
"Beep" is the function and the parameters are in the ().
Just ignore the ByVal.
From the API guide:
· dwFreq
Specifies the frequency, in hertz, of the sound. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
The dwFreq is the frequency in hertz as it says. The range is different on different computers. This model is used for windows NT which I would guess nobody has. I would guess that they would have Windows XP or a more reasent operating system.
The Range for Windows XP is 7000 max and about a 100 min. I had to figure these values. It's the lowest you can hear to the highest you can hear.
From the API Guide:
· dwDuration
Specifies the duration, in milliseconds, of the sound.
As it says the dwDuration parameter is the length in milliseconds that you want your tone to play.
A warning: Note that you can set this to a really high number and the Dark Basic Professional app will pause until the sound is complete and I have had this happen to my computer by putting the code in a do loop, SO DON'T TRY IT...and don't tell me because I told you so!
To call the dll you would use the call dll command except use () to show that you want to return something.
The dll will return a non zero value (float) if it was successful. If it didn't work then a zero would be returned.
Notice: When using windows api functions you have to keep the function the same. Can't have an lowercase (b) when it requires an uppercase!
Here's the code:
dwFreq = 1000
dwDuration = 500
Call dll(1,"Beep",dwFreq,dwDuration)
Final Code snippet:
load dll "kernel32.dll",1
dwFreq = 1000
dwDuration = 500
Call dll(1,"Beep",dwFreq,dwDuration)
Let me know if you need any more help with windows api!
gamersforsale