473,394 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

waveInGetNumDevs


Sub InitDevices()

Dim Caps As WaveInCaps, x As Long

For x = 0 To waveInGetNumDevs - 1
Call waveInGetDevCaps(x, VarPtr(Caps), Len(Caps))
If Caps.Formats And WAVE_FORMAT_1M16 Then '16-bit mono devices
Call DevicesBox.AddItem(StrConv(Caps.ProductName,
vbUnicode), x)
End If
Next x
That code is supposed to fill a listbox full of the audio devices
available, but I can't seem to be able to convert this to VB.NET. It
really doesn't like the structure(or type) of WaveInCaps. Could anyone
attempt to convert this code over? .Net really complains about
whichever method I use to send the pointer of the structure into the
API.
Any ideas?
Thanks,
Brett

Dec 22 '05 #1
1 5472
<br***********@hotmail.com> schrieb:
Dim Caps As WaveInCaps, x As Long

For x = 0 To waveInGetNumDevs - 1
Call waveInGetDevCaps(x, VarPtr(Caps), Len(Caps))
If Caps.Formats And WAVE_FORMAT_1M16 Then '16-bit mono devices
Call DevicesBox.AddItem(StrConv(Caps.ProductName,
vbUnicode), x)
End If
Next x

That code is supposed to fill a listbox full of the audio devices
available, but I can't seem to be able to convert this to VB.NET.
I have written a small working sample for you :-):

\\\
Private Declare Function waveInGetNumDevs Lib "winmm.dll" () As Int32

Private Declare Auto Function waveInGetDevCaps Lib "winmm.dll" ( _
ByVal uDeviceID As Int32, _
ByRef pwic As WAVEINCAPS, _
ByVal cbwic As Int32 _
) As Int32

Private Const MAXPNAMELEN As Int32 = 32

Private Const MMSYSERR_BASE As Int32 = 0

Private Enum MMRESULT
MMSYSERR_NOERROR = 0
MMSYSERR_ERROR = (MMSYSERR_BASE + 1)
MMSYSERR_BADDEVICEID = (MMSYSERR_BASE + 2)
MMSYSERR_NOTENABLED = (MMSYSERR_BASE + 3)
MMSYSERR_ALLOCATED = (MMSYSERR_BASE + 4)
MMSYSERR_INVALHANDLE = (MMSYSERR_BASE + 5)
MMSYSERR_NODRIVER = (MMSYSERR_BASE + 6)
MMSYSERR_NOMEM = (MMSYSERR_BASE + 7)
MMSYSERR_NOTSUPPORTED = (MMSYSERR_BASE + 8)
MMSYSERR_BADERRNUM = (MMSYSERR_BASE + 9)
MMSYSERR_INVALFLAG = (MMSYSERR_BASE + 10)
MMSYSERR_INVALPARAM = (MMSYSERR_BASE + 11)
MMSYSERR_HANDLEBUSY = (MMSYSERR_BASE + 12)
MMSYSERR_INVALIDALIAS = (MMSYSERR_BASE + 13)
MMSYSERR_BADDB = (MMSYSERR_BASE + 14)
MMSYSERR_KEYNOTFOUND = (MMSYSERR_BASE + 15)
MMSYSERR_READERROR = (MMSYSERR_BASE + 16)
MMSYSERR_WRITEERROR = (MMSYSERR_BASE + 17)
MMSYSERR_DELETEERROR = (MMSYSERR_BASE + 18)
MMSYSERR_VALNOTFOUND = (MMSYSERR_BASE + 19)
MMSYSERR_NODRIVERCB = (MMSYSERR_BASE + 20)
MMSYSERR_LASTERROR = (MMSYSERR_BASE + 20)
End Enum

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Auto)> _
Private Structure WAVEINCAPS
Public wMid As Int16
Public wPid As Int16
Public vDriverVersion As Int32
< _
MarshalAs( _
UnmanagedType.ByValTStr, _
SizeConst:=MAXPNAMELEN _
) _ _

Public szPname As String
Public dwFormats As Int32
Public wChannels As Int16
Public wReserved1 As Int16
End Structure

Private Sub Form1_Load(...) Handles MyBase.Load
Dim Caps As WAVEINCAPS
For i As Integer = 0 To waveInGetNumDevs() - 1
Dim r As MMRESULT = waveInGetDevCaps(i, Caps, Marshal.SizeOf(Caps))
If r = MMRESULT.MMSYSERR_NOERROR Then
MsgBox(Caps.szPname)
Else
Debug.WriteLine("Error " & r.ToString() & " occured!")
End If
Next i
End Sub
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Dec 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
3
by: June Li | last post by:
H I got a problem with detecting sound card with Windows x I use SDK function waveInGetNumDevs() to test if there is a sound card. But even if there is no sound card installed, the function...
0
by: June Li | last post by:
H I got a problem with detecting sound card with Windows xp I am working on an application to test microphone. First I need detect if there is a sound card installed (or integrated audio...
4
by: Sakharam Phapale | last post by:
Hi All, ..NET application does not give correct result when I used following API function . { Declare Function waveInGetNumDevs Lib "winmm.dll" () As Long MsgBox(waveInGetNumDevs)
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?
2
by: jrumanek | last post by:
Hallo, I have problem with function WaveInOpen . This function doesn't return meesage MM_WIM_OPEN? Shall YOU help me pleas? Any suggestions? Thank you!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.