types convertion from C++ API to VB.Net

  • Thread starter Thread starter ThunderMusic
  • Start date Start date
T

ThunderMusic

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
 
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
 
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
 
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
 
Back
Top