473,657 Members | 2,397 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 4520
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
2299
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
2816
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
2725
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
4752
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
2280
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
9078
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
9877
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
3962
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
8399
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
8732
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
8606
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...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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
4159
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
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.