472,784 Members | 998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 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 4437
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Aaron Prohaska | last post by:
I have just run into a problem where I have a page that posts back to itself to execute code, except when the page does the post back it somehow executes code that is in our home page for the site....
9
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
4
by: Sakharam Phapale | last post by:
Hi All, I have written following code, but waveInOpen API call gives me error no 32. Can anyone help me to solve this? Public Delegate Function callback(ByVal hw As Integer, ByVal uMsg As...
2
by: Sakharam Phapale | last post by:
Hi All, Yestrday I had problem regarding WAVEFORMAT structure in WaveInOpen API function call. Following structure works properly. But next to that didn't. Can anybody tell me why should I used...
2
by: Fred Loud | last post by:
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...
4
by: saverain | last post by:
//WaveIn.h MMRESULT IsFormatSupported(LPWAVEFORMATEX pwfx, UINT uDeviceID) { return waveInOpen ( NULL, // ptr can be NULL for query uDeviceID, // The device identifier...
3
by: jrumanek | last post by:
Hallo, I have a problem with function WaveInOpen. The function gives ERROR CODE 11 - MMSYSERR_INVALPARAM. Shall you help me please? Any sugestion?
3
by: wizche | last post by:
Hi Everybody, I'm trying to play a little with waveIn functions... My goal is to calculate if I'm listening a specified sin frequency or not. For this reason I'm going down with the...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.