I'm integrating with an SDK from my VB .net application. One of the function call requires passing a BSTR and structure pointer. It also has two other parameters that are enumerations. I don't know the datatype for these Enumerations. How do I make the call. My code is someting like this:
Dim lChannel As New SmIa.SInputChan nel
Dim lStructSize As Integer
lStructSize = Marshal.SizeOf( GetType(SmIa.SI nputChannel))
With lChannel
.bw = SmIa.Bandwidth. bwBroad
.res = SmIa.Resolution .reHigh
.type = SmIa.InputChann elId.icMicropho ne
End With
Dim lPtr As IntPtr = Marshal.AllocHG lobal(lStructSi ze)
Marshal.Structu reToPtr(lChanne l, lPtr, False)
Dim lResChannel As SmIa.SInputChan nel = CType(Marshal.P trToStructure(l Ptr, GetType(SmIa.SI nputChannel)), SmIa.SInputChan nel)
Dim lStrUser As String = "r"
Dim lStrPtr As IntPtr = Marshal.StringT oBSTR(lStrUser)
Dim lResUserName As String = Marshal.PtrToSt ringBSTR(lStrPt r)
Dim lLang As Integer = SmIa.LanguageId .lngUK
cTraining.Open( lResUserName, lResChannel, lLang, lLang)
Marshal.FreeBST R(lStrPtr)
Of these SmIa.SInputChan nel, SmIa.LanguageId are the structure and enum from the SDK.
Thanks for the help in advance
Dim lChannel As New SmIa.SInputChan nel
Dim lStructSize As Integer
lStructSize = Marshal.SizeOf( GetType(SmIa.SI nputChannel))
With lChannel
.bw = SmIa.Bandwidth. bwBroad
.res = SmIa.Resolution .reHigh
.type = SmIa.InputChann elId.icMicropho ne
End With
Dim lPtr As IntPtr = Marshal.AllocHG lobal(lStructSi ze)
Marshal.Structu reToPtr(lChanne l, lPtr, False)
Dim lResChannel As SmIa.SInputChan nel = CType(Marshal.P trToStructure(l Ptr, GetType(SmIa.SI nputChannel)), SmIa.SInputChan nel)
Dim lStrUser As String = "r"
Dim lStrPtr As IntPtr = Marshal.StringT oBSTR(lStrUser)
Dim lResUserName As String = Marshal.PtrToSt ringBSTR(lStrPt r)
Dim lLang As Integer = SmIa.LanguageId .lngUK
cTraining.Open( lResUserName, lResChannel, lLang, lLang)
Marshal.FreeBST R(lStrPtr)
Of these SmIa.SInputChan nel, SmIa.LanguageId are the structure and enum from the SDK.
Thanks for the help in advance
Comment