Index of refi


Declare Function joyGetNumDevs Lib "winmm.dll" () As Long

Platforms: Win 95/98

joyGetNumDevs returns the number of joysticks that are configured under Windows's Control Panel. This doesn't necessarily mean that all of them are connected and in working order, but there could be. The best way to see if a joystick is working is to call joyGetDevCaps and check for a return value of 0.

Example:

' Determine the number of configured joysticks and the number of ' connected joysticks.  To see if a joystick is connected, try to read information from it and see if ' the attempt is successful or not. Dim joyinfo As JOYCAPS  ' needed for the function call to see if a joystick works Dim numjoys As Long  ' receives number of configured joysticks Dim numexist As Long  ' number of existing joysticks hooked up to the computer Dim c As Integer  ' counter variable Dim retval As Long  ' return value for other functions numjoys = joyGetNumDevs()  ' determine the number of configured joysticks Debug.Print "There are"; numjoys; "joysticks configured under Windows." numexist = 0  ' initialize the number of existing joysticks For c = 0 To numjoys - 1  ' check each joystick (remember Joystick #1's ID = 0, etc.)   retval = joyGetDevCaps(c, joyinfo, Len(joyinfo))  ' try to read information   If retval = 0 Then numexist = numexist + 1  ' increment counter if the joystick is connected Next c Debug.Print "There are"; numexist; "joysticks currently connected to the computer."

Category: Joysticks

Go back to the alphabetical Function listing.
Go back to the Reference section index.


This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/j/joygetnumdevs.html



Windows API Guide
Windows API Guide - Reference - Volume 1: Version 3.0 For the MS-DOS and PC-DOS Operating Systems
ISBN: B001V0KQIY
EAN: N/A
Year: 1998
Pages: 610

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net