by Bart 'mainframe' vd Sande [gangstersoft] ()
Category: Games
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th March 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This shows how to use DirectInput in your application. Please note that you will need the DirectX 7 library for VB. Download it at
API Declarations
Public DI As DirectInput
Public DIV As DirectInputDevice
Public DID As DirectInputEnumDevices
Public DI_GUID As String
Dim DII As DirectInputDeviceInstance
Public KeyB As DIKEYBOARDSTATE
Dim DI_GUID As String
Set DI = DX.DirectInputCreate
Set DID = DI.GetDIEnumDevices(DIDEVTYPE_KEYBOARD, DIEDFL_ATTACHEDONLY)
Set DII = DID.GetItem(1)
DI_GUID = DII.GetGuidInstance
Set DIV = DI.CreateDevice(DI_GUID)
DIV.SetCommonDataFormat DIFORMAT_KEYBOARD
DIV.SetCooperativeLevel frmMain.hWnd, DISCL_BACKGROUND Or DISCL_NONEXCLUSIVE
DIV.Acquire
End Sub
Public Sub UpdateInput()
DIV.GetDeviceStateKeyboard KeyB
End Sub
No comments have been posted about This shows how to use DirectInput in your application. Please note that you will need the DirectX 7. Why not be the first to post a comment about This shows how to use DirectInput in your application. Please note that you will need the DirectX 7.