473,386 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

.Net Marshalling. How to?

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.SInputChannel
Dim lStructSize As Integer

lStructSize = Marshal.SizeOf(GetType(SmIa.SInputChannel))

With lChannel
.bw = SmIa.Bandwidth.bwBroad
.res = SmIa.Resolution.reHigh
.type = SmIa.InputChannelId.icMicrophone
End With

Dim lPtr As IntPtr = Marshal.AllocHGlobal(lStructSize)

Marshal.StructureToPtr(lChannel, lPtr, False)

Dim lResChannel As SmIa.SInputChannel = CType(Marshal.PtrToStructure(lPtr, GetType(SmIa.SInputChannel)), SmIa.SInputChannel)

Dim lStrUser As String = "r"
Dim lStrPtr As IntPtr = Marshal.StringToBSTR(lStrUser)
Dim lResUserName As String = Marshal.PtrToStringBSTR(lStrPtr)
Dim lLang As Integer = SmIa.LanguageId.lngUK

cTraining.Open(lResUserName, lResChannel, lLang, lLang)
Marshal.FreeBSTR(lStrPtr)

Of these SmIa.SInputChannel, SmIa.LanguageId are the structure and enum from the SDK.

Thanks for the help in advance
Jun 26 '08 #1
1 1098
RedSon
5,000 Expert 4TB
A quick search on this site reveals...
http://bytes.com/forum/thread214191.html
Jun 26 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Animesh | last post by:
Hi All, I don't know whethher this is possible or not. This is the result of a bad design problem. Here I go; I have a structure like this: typedef struct _s_index_entry { char *doc_id;...
2
by: Howard Kaikow | last post by:
I've got the following in a VB 6 project: Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long cntThreads As Long...
0
by: swartzbill2000 | last post by:
I am familiar with the VB6/VC6/ATL way of marshalling an incoming interface via New (VB), and then marshalling an outgoing interface with some form of Advise. To me it looks like .Net has...
2
by: RJ Lohan | last post by:
Howdy, I have a legacy DLL for which I have a problem marshalling a parameter type of char**. The function header (C++) is as so; extern "C" __declspec(dllexport) int __stdcall...
2
by: calenlas | last post by:
Hi all, I'm taking my first steps into C# <--C++ DLL Interop and unfortunately I've run into (what seems to be) a very complicated case as my first task. Perhaps someone here can help me. I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.