Hello. I have been a long time without programming for Midi instruments. And now I can't find what is wrong in my code.
The API MidiOutGetDevCaps returns no error but do not fill the structure which remains empty.
My computer is Asus N76V, Windows 10, 64 bits.
I have tryed many variations of my code like :
but the result is always the same.
I think I do something wrong but I am unable to know what. Can somebody help me please ?
THANK YOU VERY MUCH FOR YOUR HELP.
The API MidiOutGetDevCaps returns no error but do not fill the structure which remains empty.
My computer is Asus N76V, Windows 10, 64 bits.
I have tryed many variations of my code like :
- "Declare Function ..." or "Declare Auto Function ...."
- or like "Len(infoMidi_Out)" or "Marshall.sizeOf..."
- or like " Dim infoMIDI_Out As MIDIOUTCAPS" or "Dim infoMIDI_Out As New MIDIOUTCAPS"
- or "infoMIDI_Out = Nothing", this line used or deleted.
but the result is always the same.
I think I do something wrong but I am unable to know what. Can somebody help me please ?
HTML Code:
Option Explicit On
Option Strict Off
Imports System.Drawing.Bitmap
Imports System
Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Collections.Specialized
Public Class form1
Public Structure MIDIOUTCAPS ' 'Structure of 52 bytes
Dim ManufacturerID As Short
Dim ProductID As Short
Public DriverVersion As Integer
<VBFixedString(32)> Public Label As String ' Product Name.
Dim Technology As Short
Dim Voices As Short
Dim Notes As Short
Dim ChannelMask As Short
Dim Support As Integer
End Structure
' API counting the number of MidiOut ports
Public Declare Function midiOutGetNumDevs Lib "winmm.dll" () As Integer
' this returns that I have 2 Midi Out ports (ports 0 and 1)
'API giving Midi Out device informations
Public Declare Auto Function midiOutGetDevCaps Lib "winmm.dll" Alias "midiOutGetDevCapsA" (
ByVal uDeviceID As Long,
ByVal lpCaps As MIDIOUTCAPS,
ByVal uSize As Long) _ ' 32 bytes
As Long
Private Sub form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim idxOut As Integer
Dim infoMIDI_Out As MIDIOUTCAPS
Dim retour As Long
infoMIDI_Out = Nothing
For idxOut = 0 To (midiOutGetNumDevs - 1) Step 1
' display the number of Midi Out ports found
Label1.Text = (idxOut + 1) & " drivers Midi Out"
Next
idxOut = 0 ' I try to read details of port 0 only
retour = midiOutGetDevCaps(idxOut, infoMIDI_Out, Len(infoMIDI_Out))
Label2.text = "midiOutGetDevCaps retuns error n° " & retour.ToString
Label3.Text = "Len(infoMIDI_Out) = " & Len(infoMIDI_Out) ' display the lenght of the structure. Result is 52
' Display the details
Label4.Text = infoMIDI_Out.ManufacturerID.ToString
Label5.Text = infoMIDI_Out.ProductID.ToString
Label6.Text = infoMIDI_Out.DriverVersion.ToString
Label7.Text = infoMIDI_Out.Label
Label8.Text = infoMIDI_Out.Technology.ToString
End Sub
End Class