473,847 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_INVALP ARAM.

I can call waveInGetNumDev s and waveInGetDevCap s just fine. Below is the
format of the waveInOpen call and WaveFormatEx structure.

<DllImport("win mm.dll", SetLastError:=F alse, ExactSpelling:= True)> _
Public Shared Function waveInOpen(ByVa l lphWaveIn As Int32 _
, ByVal uDeviceID As Int32 _
, ByRef lpFormat As APIStructures.W aveFormatEx _
, ByVal dwCallback As Int32 _
, ByVal dwInstance As Int32 _
, ByVal dwFlags As Int32) As Int32
End Function

<StructLayout(L ayoutKind.Seque ntial, CharSet:=CharSe t.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 4531
Fred,
<DllImport("wi nmm.dll", SetLastError:=F alse, ExactSpelling:= True)> _
Public Shared Function waveInOpen(ByVa l lphWaveIn As Int32 _
, ByVal uDeviceID As Int32 _
, ByRef lpFormat As APIStructures.W aveFormatEx _
, ByVal dwCallback As Int32 _
, ByVal dwInstance As Int32 _
, ByVal dwFlags As Int32) As Int32
End Function


Try it like this

<DllImport("win mm.dll", SetLastError:=F alse, ExactSpelling:= True)> _
Public Shared Function waveInOpen(ByRe f lphWaveIn As IntPtr _
, ByVal uDeviceID As IntPtr _
, ByRef lpFormat As APIStructures.W aveFormatEx _
, 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("wi nmm.dll", SetLastError:=F alse, ExactSpelling:= True)> _
Public Shared Function waveInOpen(ByVa l lphWaveIn As Int32 _
, ByVal uDeviceID As Int32 _
, ByRef lpFormat As APIStructures.W aveFormatEx _
, ByVal dwCallback As Int32 _
, ByVal dwInstance As Int32 _
, ByVal dwFlags As Int32) As Int32
End Function


Try it like this

<DllImport("win mm.dll", SetLastError:=F alse, ExactSpelling:= True)> _
Public Shared Function waveInOpen(ByRe f lphWaveIn As IntPtr _
, ByVal uDeviceID As IntPtr _
, ByRef lpFormat As APIStructures.W aveFormatEx _
, 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
2314
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. The only reason I know that is happening is because I keep track of the pages executed by the user to see how they have traversed the site. Has anyone every seen anything like this before? Regards, Aaron Prohaska
9
2827
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 facing. Please please help me to solve this as soon as possible. So here we go ... I am not able to take the screen shot of the windows form based "Smart
5
2738
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
4763
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 Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Public Const CALLBACK_FUNCTION = &H30000
2
2286
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 Int16 and Int32 why not just Integer. Since in it's original definition they are Long, in .NET long is converted to Integer. But giving Integer it doesn't works. Even if I give all elements as int32 it doesn't works.
2
311
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 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 _ ,...
4
9087
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 pwfx, // Defines the requested // format. NULL, // No callback NULL, // No instance data
3
9901
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
3991
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 samplerate... How can I be sure of the sampling rate set on my device? If I declare waveFormat.nSamplesPerSec = 9441000; waveInOpen return NO error.. (same if I put 500 Hz) But I'm not really sure that's working (9 MHz!!)... For example if I want to find a...
0
9882
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9727
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10982
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10645
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10335
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5909
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4116
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3160
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.