471,339 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Problem using waveInOpen from VB.NET

I'm having a problem calling waveInOpen from a VB.NET application, every time
I call it I get a return value of 11 which is MMSYSERR_INVALPARAM.

I can call waveInGetNumDevs and waveInGetDevCaps just fine. Below is the
format of the waveInOpen call and WaveFormatEx structure.

<DllImport("winmm.dll", SetLastError:=False, ExactSpelling:=True)> _
Public Shared Function waveInOpen(ByVal lphWaveIn As Int32 _
, ByVal uDeviceID As Int32 _
, ByRef lpFormat As APIStructures.WaveFormatEx _
, ByVal dwCallback As Int32 _
, ByVal dwInstance As Int32 _
, ByVal dwFlags As Int32) As Int32
End Function

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto, Pack:=1)> _
Public Structure WaveFormatEx
Public FormatTag As Int16
Public Channels As Int16
Public SamplesPerSec As Int32
Public AvgBytesPerSec As Int32
Public BlockAlign As Int16
Public BitsPerSample As Int16
Public ExtraDataSize As Int16
End Structure

A sample solution is available upon request. Any help would be much
appreciated.

--
Fred Loud
MCP
Jul 21 '05 #1
2 4322
Fred,
<DllImport("winmm.dll", SetLastError:=False, ExactSpelling:=True)> _
Public Shared Function waveInOpen(ByVal lphWaveIn As Int32 _
, ByVal uDeviceID As Int32 _
, ByRef lpFormat As APIStructures.WaveFormatEx _
, ByVal dwCallback As Int32 _
, ByVal dwInstance As Int32 _
, ByVal dwFlags As Int32) As Int32
End Function


Try it like this

<DllImport("winmm.dll", SetLastError:=False, ExactSpelling:=True)> _
Public Shared Function waveInOpen(ByRef lphWaveIn As IntPtr _
, ByVal uDeviceID As IntPtr _
, ByRef lpFormat As APIStructures.WaveFormatEx _
, ByVal dwCallback As IntPtr _
, ByVal dwInstance As IntPtr _
, ByVal dwFlags As Int32) As Int32
End Function

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2
Thanks for the change, I updated the app to use IntPtr for the device handle
instead of Int32s and it worked the first time.

Thanks again for the hugh help!
--
Fred Loud
MCP
"Mattias Sjögren" wrote:
Fred,
<DllImport("winmm.dll", SetLastError:=False, ExactSpelling:=True)> _
Public Shared Function waveInOpen(ByVal lphWaveIn As Int32 _
, ByVal uDeviceID As Int32 _
, ByRef lpFormat As APIStructures.WaveFormatEx _
, ByVal dwCallback As Int32 _
, ByVal dwInstance As Int32 _
, ByVal dwFlags As Int32) As Int32
End Function


Try it like this

<DllImport("winmm.dll", SetLastError:=False, ExactSpelling:=True)> _
Public Shared Function waveInOpen(ByRef lphWaveIn As IntPtr _
, ByVal uDeviceID As IntPtr _
, ByRef lpFormat As APIStructures.WaveFormatEx _
, ByVal dwCallback As IntPtr _
, ByVal dwInstance As IntPtr _
, ByVal dwFlags As Int32) As Int32
End Function

Mattias

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

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Aaron Prohaska | last post: by
5 posts views Thread by IkBenHet | last post: by
4 posts views Thread by Sakharam Phapale | last post: by
2 posts views Thread by Sakharam Phapale | last post: by
2 posts views Thread by Fred Loud | last post: by
4 posts views Thread by saverain | last post: by
3 posts views Thread by jrumanek | last post: by

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.