Ragazzi devo usare questa API in VB.net poichè sto trasportando il progetto dal VB6
codice:
Private Declare Function waveInGetDevCaps Lib "winmm" Alias "waveInGetDevCapsA" (ByVal uDeviceID As Long, ByVal WaveInCapsPointer As Long, ByVal WaveInCapsStructSize As Long) As Long
nel codice esiste la struttura:
codice:
Private Structure WaveInCaps
Public ManufacturerID As Integer
Public ProductID As Integer
Public DriverVersion As Long
Public ProductName() As Byte
Public Formats As Long
Public Channels As Integer
Public Reserved As Integer
End Structure
nel codice usavo VarPtr per ottenere il puntatore di "caps" (struttura sopra):
codice:
waveInGetDevCaps(1, VarPtr(caps), Len(caps))
Ora su VB.net come posso ottenere l'indirizzo della variabile?
Ho provato con GCHandle sostituendo la vecchia varptr:
codice:
Public Shared Function VarPtr(ByVal o As Object) As Long
Dim gh As GCHandle = GCHandle.Alloc(o, GCHandleType.Pinned)
Dim gh2 As Long = gh.AddrOfPinnedObject.ToInt32
gh.Free()
Return gh2
End Function
e durante l'esecuzione alla riga:
codice:
Dim gh As GCHandle = GCHandle.Alloc(o, GCHandleType.Pinned)
ottengo
"L'oggetto contiene dati non copiabili o non primitivi."
Non so come risolvere...