Passing a type to a DLL API

BlitzMax Forums/BlitzMax Programming/Passing a type to a DLL API

All,
I have this API function:
Extern "Os"
Function midiOutGetDevCapsA( uDeviceID:Int, lpCaps:MIDIOUTCAPS, uSize:Int)
End Extern


and this BMAX type structure:
Const MAXPNAMELEN = 32

Type MIDIOUTCAPS
	Field wMid:Short
	Field wPid:Short
	Field vDriverVersion:Short ' MMVERSION 
	Field szPname:String[MAXPNAMELEN]
	Field wTechnology:Short
	Field wVoices:Short
	Field wNotes:Short
	Field wChannelMask:Short
	Field dwSupport:Int
EndType


Question: how do I pass the type structure to the function above ?

I've tryed several ways, for example:
cap:MIDIOUTCAPS = new MIDIOUTCAPS

1)
midiOutGetDevCapsA(n, cap, SizeOf(MIDIOUTCAPS))

2)
midiOutGetDevCapsA(n, Byte Ptr(cap), SizeOf(MIDIOUTCAPS))

3)
midiOutGetDevCapsA(n, Int Ptr(cap), SizeOf(MIDIOUTCAPS))

4)
midiOutGetDevCapsA(n, Byte Ptr(cap.wmid), SizeOf(MIDIOUTCAPS))

5)
midiOutGetDevCapsA(n, Int Ptr(cap.wmid), SizeOf(MIDIOUTCAPS))

and so on...

This is a VB6 code that use the same function, and works
Const MAXPNAMELEN = 32
Private Type MIDIOUTCAPS
    wMid As Integer
    wPid As Integer
    vDriverVersion As Long
    szPname As String * MAXPNAMELEN
    wTechnology As Integer
    wVoices As Integer
    wNotes As Integer
    wChannelMask As Integer
    dwSupport As Long
End Type

Private Type test
    abc As Integer
End Type

Private Declare Function midiOutGetDevCaps Lib "winmm.dll" Alias "midiOutGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As MIDIOUTCAPS, ByVal uSize As Long) As Long
Private Declare Function midiOutGetNumDevs Lib "winmm" () As Integer
Private Sub Form_Paint()
    'KPD-Team 1999
    'URL: <a href="http://www.allapi.net/" target="_blank">http://www.allapi.net/</a>
    'E-Mail: KPDTeam@...
    Dim MidiCaps As MIDIOUTCAPS
    Dim Cnt As Long
    
    'Clear the form
    Me.Cls
    'Get the number of installed MIDI devices
    Me.Print "Available midi devices:" + Str$(midiOutGetNumDevs)
    For Cnt = 0 To midiOutGetNumDevs - 1
        'Get the device name and capabilities
        Me.Print midiOutGetDevCaps(Cnt, MidiCaps, Len(MidiCaps))
        Me.Print "Device name" + Str$(Cnt + 1) + ": " + MidiCaps.szPname
    Next Cnt
End Sub


Could someone of you explain in detail how to pass a type structure to such a DLL ?

And also, is this conversion table right ?

VB Integer = Bmax Short
VB Long = Bmax Int

C WORD = Bmax Short
C DWORD = Bmax Int

Sergio.