473,378 Members | 1,436 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,378 software developers and data experts.

types convertion from C++ API to VB.Net

Hi,
Sorry but this message is a bit long, but I really need your help here.

I'm trying to use some API functions that use some trivial types like long
pointers to a structure. I just can figure out which type to use in the API
declaration in my code

take as an example this declaration :

MMRESULT acmFormatSuggest(HACMDRIVER had, LPWAVEFORMATEX pwfxSrc,
LPWAVEFORMATEX pwfxDst, DWORD cbwfxDst, DWORD fdwSuggest);

the parameter pwfxSrc takes a long pointer to a WAVEFORMATEX structure
variable. In my VB declaration of this function, should I just use a Byref
pwfxDst as WAVEFORMATEX or will I have to do some other trivial things with
IntPtr?!?
right now I declared it like this :

Declare Auto Function acmFormatSuggest Lib "MsAcm32.dll" (ByVal had As
IntPtr, ByRef pwfxSrc As WAVEFORMATEX, ByRef pwfxDst As WAVEFORMATEX, ByVal
cbwfxDst As Int32, ByVal fdwSuggest As Int32) As Int32

I mean, what I have to send is not even some WAVEFORMATEX data, I will have
to send a MPEGLAYER3WAVEFORMAT structure to it, which contains the data in
WAVEFORMATEX but also contains other informations needed for Mpeg layer 3
operations. So will I have to put the type to WAVEFORMATEX (as it is
supposed to be, I guess) or MPEGLAYER3WAVEFORMAT as I will have to use or
IntPtr to send the pointer (which I don't know where to get in VB.NET)?

I know I could also include the group
microsoft.public.win32.programmer.mmedia but I think this question is more a
language question than a multimedia question. I mean, it could be any other
API function, I just took this one because it's one I have to use in my
project, but I have many others with the same concern.

Thanks for your help

ThunderMusic
Dec 5 '05 #1
3 1577
>I mean, what I have to send is not even some WAVEFORMATEX data, I will have
to send a MPEGLAYER3WAVEFORMAT structure to it, which contains the data in
WAVEFORMATEX but also contains other informations needed for Mpeg layer 3
operations. So will I have to put the type to WAVEFORMATEX (as it is
supposed to be, I guess) or MPEGLAYER3WAVEFORMAT as I will have to use or
IntPtr to send the pointer (which I don't know where to get in VB.NET)?


For pwfxSrc you can specify the actual type you want to pass in,
MPEGLAYER3WAVEFORMAT in this case.

For pwfxDst you will probably have to declare it ByVal As IntPtr and
pass in a dynamically allocated buffer since the output can be of
variable length.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 5 '05 #2
How can I have a pointer to a structure in VB.NET?

dim Dest as WAVEFORMATEX

how can I have a pointer to Dest to put in IntPtr?

thanks

"Mattias Sjögren" <ma********************@mvps.org> a écrit dans le message
de news: uT***************@TK2MSFTNGP11.phx.gbl...
I mean, what I have to send is not even some WAVEFORMATEX data, I will
have
to send a MPEGLAYER3WAVEFORMAT structure to it, which contains the data in
WAVEFORMATEX but also contains other informations needed for Mpeg layer 3
operations. So will I have to put the type to WAVEFORMATEX (as it is
supposed to be, I guess) or MPEGLAYER3WAVEFORMAT as I will have to use or
IntPtr to send the pointer (which I don't know where to get in VB.NET)?


For pwfxSrc you can specify the actual type you want to pass in,
MPEGLAYER3WAVEFORMAT in this case.

For pwfxDst you will probably have to declare it ByVal As IntPtr and
pass in a dynamically allocated buffer since the output can be of
variable length.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Dec 5 '05 #3
How can I have a pointer to a structure in VB.NET?


You allocate a buffer from a native heap with one of the Marshal.Alloc
methods, and then copy your struct to/from that buffer with
Marshal.PtrToStructure and Marshal.StructureToPtr.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 6 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Petr Studenovsky | last post by:
Hello I made small GUI test program in Visual Basic NET for SQL communication. I need some help with these problems. problem 1) If I change some settings in datagrid from properties window...
0
by: Konstantin Kivi | last post by:
I have problems getting character set convertion to work in 4.1.4 gamma under linux. Can sombody point me to the online recource other than standard MySQL doc so that I get more information.
6
by: Chiller | last post by:
I'm in the process of writing a class that performs functions on a Distance object. The object is created by entering details as "Distance a (5, km)" or "Distance b (3, cm)" etc. I wish to write...
1
by: Vidar | last post by:
I have a problem in dotNET XSL convertion object. (XMLTRANSFORM) It won't convert UTF-8 to ISO-8859-1 I use this stylesheet for konvertion: <?xml version="1.0" encoding="ISO-8859-1"?> <!--...
0
by: McKoy | last post by:
Hi, I'm translating some code from C++ to C#, but I don't know how to change the code below to get it working under C# ...., I've tried explicity convertion, but without any results :( Please...
4
by: juli | last post by:
Good afternoon! I have an error while trying to convert to DateTime ,here is the code and the error: ArrayList al = new ArrayList(); temp_str=Line.Split(' '); al.Add(temp_str); //...
8
by: juli | last post by:
I am trying to convert an object of a class which is derived from collectionbase class.It's not working: while ((line = file.ReadLine()) != null && line.IndexOf(" ")!=-1) { al.Add(line); }...
7
by: Alberto | last post by:
Actually I have two quantities (4.61) stored as decimal numbers. Why if I try to sum them the result is 9.23 if the correct value is 9.22? Thank you
0
by: isore | last post by:
Convertion php to asp.net : PB lecture fichier .ini URGENT URGENT URGENT URGENT URGENT URGENT J'ai un code en php (http://parisports.free.fr) mais le client veut le même en asp.net J'ai...
3
by: ThunderMusic | last post by:
Hi, Sorry but this message is a bit long, but I really need your help here. I'm trying to use some API functions that use some trivial types like long pointers to a structure. I just can figure...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...

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.