Passing a type to a DLL API

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

Sorry for the double post - I've had a quick idea: This gets around the problem using 4 longs (giving 8*4=32 bytes) to create the padding where the string is supposed to be stored.

Hopefully it is a bit easier to understand (no C code or Banks required!)

Edit: I've just seen Mark's own thread in the Beginners Area - this is what he suggested as well. Doh!

Extern "Win32"
	Function midiOutGetDevCapsA(uDeviceID:Int,lpCaps:Byte Ptr,uSize:Int)
End Extern

Type MIDICaps
	Field wMid:Short
	Field wPid:Short
	Field vDriverVersion:Int
	
	Field padA:Long
	Field padB:Long
	Field padC:Long
	Field padD:Long
	
	Field wTechnology:Short
	Field wVoices:Short
	Field wNotes:Short
	Field wChannelMask:Short
	Field dwSupport:Int
End Type

Local caps:MIDICaps=New MIDICaps
Local capsPtr:Byte Ptr=Byte Ptr(caps)

midiOutGetDevCapsA(0,capsPtr,SizeOf(caps))

Print bufferToString(capsPtr+8)

Function bufferToString:String(buf:Byte Ptr)
	Local i:Int=0
	Local result:String
	
	While (buf[i] <> 0)
		result = result + Chr(buf[i])
		i :+ 1
	Wend
	
	Return result
End Function